In my android app I have
SharedPreferences usernamePref = context.getSharedPreferences(USERNAME_PREF, context.MODE_PRIVATE);
String username = usernamePref.getString(USERNAME_PREF, ERROR);
SharedPreferences emailPref = context.getSharedPreferences(EMAIL_PREF, context.MODE_PRIVATE);
String email = emailPref.getString(EMAIL_PREF, ERROR);
SharedPreferences passwordPref = context.getSharedPreferences(PASSWORD_PREF, context.MODE_PRIVATE);
String password = usernamePref.getString(PASSWORD_PREF, ERROR);
The reason this is confusing me is because the key is being used twice, which seems redundant. So I am wondering, is it possible to just get all the preferences from a single SharedPreferences object?
This is the way I typically do it:
Note: You will want to be editting the single SharedPreferences for your app, not individual as you have it now. To edit it this way do the following: