open class StringSharedPreferenceUpdater : Preference.OnPreferenceChangeListener { override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean { val newStringValue = newValue as? String ?: return false preference.context.settings().preferences.edit { putString(preference.key, newStringValue) } return true } }
Updates the corresponding [android.content.SharedPreferences] when the String [Preference] is changed. The preference key is used as the shared preference key.