PreferencesFactory

public final class PreferencesFactory


Summary

Public constructors

Public methods

static final @NonNull Preferences

Construct a Preferences object with a list of Preferences.Pair.

static final @NonNull Preferences

Get a new empty Preferences.

static final @NonNull MutablePreferences

Construct a MutablePreferences object with a list of Preferences.Pair.

Public constructors

PreferencesFactory

public final PreferencesFactory()

Public methods

create

public static final @NonNull Preferences create(Preferences.Pair<?> pairs)

Construct a Preferences object with a list of Preferences.Pair. Comparable to mapOf().

Example usage:

val counterKey = intPreferencesKey("counter")
val preferences = preferencesOf(counterKey to 100)
Parameters
Preferences.Pair<?> pairs

the key value pairs with which to construct the preferences

createEmpty

public static final @NonNull Preferences createEmpty()

Get a new empty Preferences.

Returns
@NonNull Preferences

a new Preferences instance with no preferences set

createMutable

public static final @NonNull MutablePreferences createMutable(Preferences.Pair<?> pairs)

Construct a MutablePreferences object with a list of Preferences.Pair. Comparable to mapOf().

Example usage:

val counterKey = intPreferencesKey("counter")
val preferences = mutablePreferencesOf(counterKey to 100)
Parameters
Preferences.Pair<?> pairs

the key value pairs with which to construct the preferences