I've been trying to save some state variables in the SharedPrefs, this
seems to work fine when onPause, and onStop are called but not when
OnDestroy() is called. When that happens the next time my activity
loads the preference values have disappeared.

Here is the code I use to save the variables:

SharedPreferences settings = getSharedPreferences("PrivateVariables",
MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putBoolean("playingState", playingState);
prefEditor.putString("songInfo", songInfo);
prefEditor.commit();

and here is how I retrieve them:

prefs = PreferenceManager.getDefaultSharedPreferences(context);
playingState = prefs.getBoolean("playingState", true);
songInfo = prefs.getString("songInfo", " No Value ");

Is anything I'm doing obviously wrong?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to