PreferencesKeys

public final class PreferencesKeys


Summary

Public methods

static final @NonNull Preferences.Key<@NonNull Boolean>

Get a key for a Boolean preference.

static final @NonNull Preferences.Key<@NonNull Double>

Get a key for a Double preference.

static final @NonNull Preferences.Key<@NonNull Float>

Get a key for a Float preference.

static final @NonNull Preferences.Key<@NonNull Integer>

Get a key for an Int preference.

static final @NonNull Preferences.Key<@NonNull Long>

Get a key for an Long preference.

static final @NonNull Preferences.Key<@NonNull String>

Get a key for a String preference.

static final @NonNull Preferences.Key<@NonNull Set<@NonNull String>>

Get a key for a String Set preference.

Public methods

booleanKey

@NonNull
public static final Preferences.Key<@NonNull BooleanbooleanKey(@NonNull String name)

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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Boolean>

the Preferences.Key for name

doubleKey

@NonNull
public static final Preferences.Key<@NonNull DoubledoubleKey(@NonNull String name)

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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Double>

the Preferences.Key for name

floatKey

@NonNull
public static final Preferences.Key<@NonNull FloatfloatKey(@NonNull String name)

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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Float>

the Preferences.Key for name

intKey

@NonNull
public static final Preferences.Key<@NonNull IntegerintKey(@NonNull String name)

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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Integer>

the Preferences.Key for name

longKey

@NonNull
public static final Preferences.Key<@NonNull LonglongKey(@NonNull String name)

Get a key for an Long 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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Long>

the Preferences.Key for name

stringKey

@NonNull
public static final Preferences.Key<@NonNull StringstringKey(@NonNull String name)

Get a key for a String 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
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull String>

the Preferences.Key for name

stringSetKey

@NonNull
public static final Preferences.Key<@NonNull Set<@NonNull String>> stringSetKey(@NonNull String name)

Get a key for a String Set 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.

Note: sets returned by DataStore are unmodifiable and will throw exceptions if mutated.

Parameters
@NonNull String name

the name of the preference

Returns
Preferences.Key<@NonNull Set<@NonNull String>>

the Preferences.Key<Set> for name