Open tarunattri opened 6 years ago
Did you use common preference filename for your shared preferences? Which context passed in SecurePreferences constructor?
Problem somehow can be caused by decryption itself, try to breakpoint encryptedValue in SecurePreferences to check it's presence:
@Override
public String getString(String key, String defaultValue) {
final String encryptedValue = sharedPreferences.getString(
SecurePreferences.hashPrefKey(key), null);
String decryptedValue = decrypt(encryptedValue);
if (encryptedValue != null && decryptedValue != null) {
return decryptedValue;
} else {
return defaultValue;
}
}
PFB my answers inline : Did you use common preference filename for your shared preferences? : Yes I used common preference File name. Which context passed in SecurePreferences constructor? IN Application class's onCreate(), context of application is passed. In case of LauncherActivity class, context of Launcher Activity is passed.
Problem somehow can be caused by decryption itself : If it was problem caused by decryption, than it would exist everywhere, but in my case only in Application class's onCreate it is returning null.
I hope it clears the issue.
In my use case I have to check for a String stored in SecuredPreference in Application class onCreate() method.
For that I try to get the String from SecuredPreference in onCreate of MyApplication class. but here most of the times, SecuredPreference returns null values.
If i add same code in my activity, it returns non null value.
Looks like SecuredPreference is taking time to intialize. Any hints on why this is happening. Let me know in case additional info is needed for this.