PreferencesFactory

Added in 1.0.0

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

public static final @NonNull 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

public static final @NonNull Preferences createEmpty()

Get a new empty Preferences.

Returns
@NonNull Preferences

a new Preferences instance with no preferences set

public static final @NonNull 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