Instances of SharedPreferences in different SActivites share an inconsistent view of the data

Ask by : Some Noob Student November 04, 2012 03:55

I was using SharedPreferences and everything was working fine.

Then I started tweaking the UI. I added HoloEverywhere as a dependency and extended SActivity instead of Activity. Now none of the SharedPreferences work.

mPrefs = mCtx.getSharedPreferences(ctx.getPackageName(),
mEditor = mPrefs.edit();

This is how I initialized my SP using android's SP at first. I noticed HE also has extended SP so I changed my code to using HE's PreferenceManager and SharedPreferences.

mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
mEditor = mPrefs.edit();

However, none of my operations are still being saved into SP. Am I doing anything wrong here?

View original question

Answer by : Some Noob StudentNovember 04, 2012 03:55

It turns out the behavior I have observed was indeed unexpected behavior. After reporting it, the author has fixed it. Kudos to him.

View original answer