Based on the following code, can you tell me how to refresh the PreferenceActivity window to show changes in the settings immediately? For example: the user taps the master chime toggle checkbox to true (ticked), I would like the user to immediately see the other settings such as the ChimeOn15Past checkbox also be be true (ticked)
SharedPreferences.Editor prefEditor = clockSettings.edit(); // Allow the settings to be changed.
if (booleanMasterChimeToggle == true) {
prefEditor.putBoolean("ChimeOnTheHour", true);
prefEditor.putBoolean("ChimeOn15Past", true);
prefEditor.putBoolean("ChimeOn30Past", true);
prefEditor.putBoolean("ChimeOn45Past", true);
strNotifyMessage = "Full chiming has now been set.";
} else {
prefEditor.putBoolean("ChimeOnTheHour", false);
prefEditor.putBoolean("ChimeOn15Past", false);
prefEditor.putBoolean("ChimeOn30Past", false);
prefEditor.putBoolean("ChimeOn45Past", false);
strNotifyMessage = "Full chiming has now been disabled.";
}
Nikolay’s answer is correct. I just want to add some code here to illustrate his point more clearly.
In short,
PreferenceActivityis not designed to refresh its values from the persistent storage once it is started. Instead of usingSharedPreferences.Editorto modify and commit additional changes like you did in your code, it is better to make the changes into the localPreferenceManagerobject which will be committed by thePreferenceActivityin its normal lifecycle.