SharedPreferences.onSharedPreferenceChangeListener not being called consistently

I’m registering a preference change listener like this (in the onCreate() of my main activity): SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() { public void onSharedPreferenceChanged( SharedPreferences prefs, String key) { System.out.println(key); } }); The trouble is, the listener is not always called. It works for the first few times a preference is changed, and … Read more

How do I display the current value of an Android Preference in the Preference summary?

This must come up very often. When the user is editing preferences in an Android app, I’d like them to be able to see the currently set value of the preference in the Preference summary. Example: if I have a Preference setting for “Discard old messages” that specifies the number of days after which messages … Read more