SharedPreferences OnSharedPreferenceChangeListener alternative for legacy code (if you cannot update all listeners or don't want to mix SharedPreferences with settings):
Use Preference.OnPreferenceChangeListener, but do not use the preference.getEntry () function, which will return the old value. Instead, get the new value through the newValue parameter, get your index in the entryValues ββarray and get the record by index in the record array.
public OnPreferenceChangeListener prefListener = new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) {
This, of course, is not suitable for performance, but until it runs many times, it may suit you.
Diana source share