I\'m developing an application in which I\'m storing username and password in SharedPreferences. All things are working fine for me, s
Make sure that you are using the same file to save and retrieve. This made me look really dumb :(
// When saving
public SharedPreferences.Editor getEditor(Activity activity, int mode) {
SharedPreferences sharedPref = activity.getApplicationContext().getSharedPreferences(PreferenceConstants.SWAGGER_USER_PREFS, mode);
SharedPreferences.Editor editor = sharedPref.edit();
return editor;
}
// When getting it
public SharedPreferences getSharedPref(Activity activity, int mode) {
SharedPreferences sharedPref = activity.getSharedPreferences(PreferenceConstants.SWAGGER_USER_PREFS, mode);
return sharedPref;
}