Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

androidx.datastore.preferences.core

Classes

MutablePreferences

Mutable version of Preferences.

Preferences

Preferences and MutablePreferences are a lot like a generic Map and MutableMap keyed by the Preferences.

Top-level functions summary

Preferences.Key<Boolean>

Get a key for a Boolean preference.

Preferences.Key<Double>

Get a key for a Double preference.

Preferences

Get a new empty Preferences.

Preferences.Key<Float>

Get a key for a Float preference.

Preferences.Key<Int>

Get a key for an Int preference.

Preferences.Key<Long>

Get a key for an Long preference.

MutablePreferences

Construct a MutablePreferences object with a list of Preferences.

Preferences
preferencesOf(vararg pairs: Preferences.Pair<*>)

Construct a Preferences object with a list of Preferences.

Preferences.Key<String>

Get a key for a String preference.

Preferences.Key<Set<String>>

Get a key for a String Set preference.

Extension functions summary

For DataStore
suspend Preferences
DataStore<Preferences>.edit(transform: suspend (MutablePreferences) -> Unit)

Edit the value in DataStore transactionally in an atomic read-modify-write operation.

Top-level functions

booleanPreferencesKey

@JvmName("booleanKey") fun booleanPreferencesKey(name: String): Preferences.Key<Boolean>

Get a key for a Boolean preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
name: String the name of the preference
Return
the Preferences.Key for name

doublePreferencesKey

@JvmName("doubleKey") fun doublePreferencesKey(name: String): Preferences.Key<Double>

Get a key for a Double preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
name: String the name of the preference
Return
the Preferences.Key for name

emptyPreferences

@JvmName("createEmpty") fun emptyPreferences(): Preferences

Get a new empty Preferences.

Return
a new Preferences instance with no preferences set

floatPreferencesKey

@JvmName("floatKey") fun floatPreferencesKey(name: String): Preferences.Key<Float>

Get a key for a Float preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
name: String the name of the preference
Return
the Preferences.Key for name

intPreferencesKey

@JvmName("intKey") fun intPreferencesKey(name: String): Preferences.Key<Int>

Get a key for an Int preference. You should not have multiple keys with the same name (for use with the same Preferences). Using overlapping keys with different types can result in ClassCastException.

Parameters
name: String the name of the preference
Return
the Preferences.Key for name

longPreferencesKey

@JvmName("longKey") fun longPreferencesKey(name: