secure-preferences
secure-preferences copied to clipboard
Empty SecurePreferences
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.name_preferences 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.
Thanks for reporting this, I'll look into
Hopefully this gets resolved
@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.
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;