When you do this sEditor.putString(PREF_EMAIL,email);
, the first parameter is the key and not the value. So what happens is in your preference the value of email is saved for the KEY PREF_EMAIL
.
Hence the key is never changing. Your shared preference are Key-ValuePair
kind of collections. The value of String PREF_EMAIL
is what you have defined in the line – public static final String PREF_EMAIL = "email";
i.e. email and will always remain the same.
The value of preference saved with the identifier key as PREF_EMAIL
changes.
so your Shared Preference will be saved as –
email = "[email protected]"
// this is just an example representation.
solved Can the value of final static field change in android?