set

operator fun <T> set(key: Preferences.Key<T>, value: T)(source)

Set a key value pair in MutablePreferences.

Example usage: val COUNTER_KEY = intPreferencesKey("counter")

// Once edit completes successfully, preferenceStore will contain the incremented counter. preferenceStore.edit { prefs: MutablePreferences -> prefs\[COUNTER_KEY\] = prefs\[COUNTER_KEY\] :? 0 + 1 }

Parameters

key

the value to set the preference to