scottyab / secure-preferences

Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.
1.53k stars 235 forks source link

Empty SecurePreferences #47

Open gafful opened 8 years ago

gafful commented 8 years ago

Anytime the app goes to the background, it looses the SecurePreferences object. And when a new one is created with the same key as was used to create initially, the object becomes available and everything works fine. But after a while, sometimes, when creating (re-initializing) the SecurePreferences object, the file gets renamed to _com.package.namepreferences somehow, and a new file is created. So when a query is made it always returns the default value since the file is empty. So now there'll be 2 files. I monitored with the Android Device Monitor. A workaround is to check if empty then get the other file instead.

scottyab commented 8 years ago

Thanks for reporting this, I'll look into

peterbetos commented 8 years ago

Hopefully this gets resolved

zecatman commented 7 years ago

@peterbetos could you please tell me how and when it gets solved? The problem exists in version 0.1.4. Is the problem solved in the master branch? Thank you for your feedback.

macdonaldj commented 7 years ago

one issue i found was in following method after doing handlePasswoordChange

private SharedPreferences getSharedPreferenceFile(Context context, String prefFilename) {
        this.sharedPrefFilename = sharedPrefFilename ;

this caused the filename to be null and created new pref file. needs to be

private SharedPreferences getSharedPreferenceFile(Context context, String prefFilename) {
        this.sharedPrefFilename = prefFilename;