MutablePreferences

Mutable version of Preferences. Allows for creating Preferences with different key-value pairs.

Functions

Link copied to clipboard
open override fun asMap(): Map<Preferences.Key<*>, Any>

Retrieve a map of all key preference pairs. The returned map is unmodifiable, and attempts to mutate it will throw runtime exceptions.

Link copied to clipboard
fun clear()
Link copied to clipboard
open operator override fun <T> contains(key: Preferences.Key<T>): Boolean

Returns true if this Preferences contains the specified key.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open operator override fun <T> get(key: Preferences.Key<T>): T?

Get a preference with a key. If the key is not set, returns null.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
operator fun minusAssign(key: Preferences.Key<*>)

Removes the preference with the given key from this MutablePreferences. If this Preferences does not contain the key, this is a no-op.

Link copied to clipboard
operator fun plusAssign(pair: Preferences.Pair<*>)

Appends or replaces all pair to this MutablePreferences.

operator fun plusAssign(prefs: Preferences)

Appends or replaces all pairs from prefs to this MutablePreferences. Keys in prefs will overwrite keys in this Preferences.

Link copied to clipboard
fun putAll(vararg pairs: Preferences.Pair<*>)

Appends or replaces all pairs to this MutablePreferences.

Link copied to clipboard
fun <T> remove(key: Preferences.Key<T>): T

Remove a preferences from this MutablePreferences.

Link copied to clipboard
operator fun <T> set(key: Preferences.Key<T>, value: T)

Set a key value pair in MutablePreferences.

Link copied to clipboard

Gets a mutable copy of Preferences which contains all the preferences in this Preferences. This can be used to update your preferences without building a new Preferences object from scratch in DataStore.updateData.

Link copied to clipboard

Gets a read-only copy of Preferences which contains all the preferences in this Preferences.

Link copied to clipboard
open override fun toString(): String

For better debugging.