I am using a SharedPreferences in Android.Everything works great in the same session.
However once I relaunch the application, all of the preferences that were set from the previous session are lost.
Is there anything I need to specify to tell the SharedPreferences to hang around from run to run?
I am creating the preferences by calling
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
Then I set properties by e.g.
preferences.edit().putString(key, value);
and I get it by
preferences.getString(key, defaultValue);
Thanks, Victor
SharedPreferences are persistent accross relaunch, restart, I think the problem is you are not commiting the preferences, use following to store values in preferences:
Preferences.Editor edit=preferences.edit();
edit.putString(key, value);
edit.commit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With