Android: Setting preferences programmatically

I’ve been having kind of the same problem. My solution was to use the default shared preferences instead of manually created preferences with a given name.

Change the reference to SharedPreferences from this:

SharedPreferences settings = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);

to this:

SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);

and see if that makes any difference.

Leave a Comment