PreferencesFactory

public final class PreferencesFactory


Summary

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 methods

create

@NonNull
public static final Preferences create(@NonNull Preferences.Pair<@NonNull ?> 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
@NonNull Preferences.Pair<@NonNull ?> pairs

the key value pairs with which to construct the preferences

createEmpty

@NonNull
public static final Preferences createEmpty()

Get a new empty Preferences.

Returns
Preferences

a new Preferences instance with no preferences set

createMutable

@NonNull
public static final MutablePreferences createMutable(@NonNull Preferences.Pair<@NonNull ?> 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
@NonNull Preferences.Pair<@NonNull ?> pairs

the key value pairs with which to construct the preferences