I just realized that in different Activities, I use different SharedPreferences. For example, I have things like this:
SharedPreferences prefs = PreferenceManager.
getDefaultSharedPreferences( LoginActivity.this);
and
SharedPreferences prefs = PreferenceManager.
getDefaultSharedPreferences( ProblemioActivity.this);
and then I have been putting data into the prefs object.
But my data seems to persist. How is that possible? Should I have been using something like this:
activity.getSharedPreference("SomeKey", Mode);
Those aren’t different shared preferences. They are the same! In both cases, you are passing the application context via the activity instance.
To use multiple shared preferences, you can specify a name with
Context#getSharedPreferences(java.lang.String, int)