PreferencesKeys
public final class PreferencesKeys
Summary
Public methods |
|
---|---|
static final @NonNull Preferences.Key<@NonNull Boolean> |
booleanKey(@NonNull String name) Get a key for a Boolean preference. |
static final @NonNull Preferences.Key<@NonNull byte[]> |
byteArrayKey(@NonNull String name) Get a key for an ByteArray 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>> |
stringSetKey(@NonNull String name) Get a key for a String Set preference. |
Public methods
booleanKey
public static final @NonNull Preferences.Key<@NonNull Boolean> booleanKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull Boolean> |
the Preferences.Key |
byteArrayKey
public static final @NonNull Preferences.Key<@NonNull byte[]> byteArrayKey(@NonNull String name)
Get a key for an ByteArray 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: ByteArrays returned by DataStore are copies. Mutating their state will do nothing to the underlying data store. They must be set explicitly.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull byte[]> |
the Preferences.Key |
doubleKey
public static final @NonNull Preferences.Key<@NonNull Double> doubleKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull Double> |
the Preferences.Key |
floatKey
public static final @NonNull Preferences.Key<@NonNull Float> floatKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull Float> |
the Preferences.Key |
intKey
public static final @NonNull Preferences.Key<@NonNull Integer> intKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull Integer> |
the Preferences.Key |
longKey
public static final @NonNull Preferences.Key<@NonNull Long> longKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull Long> |
the Preferences.Key |
stringKey
public static final @NonNull Preferences.Key<@NonNull String> stringKey(@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.
Returns | |
---|---|
@NonNull Preferences.Key<@NonNull String> |
the Preferences.Key |
stringSetKey
public static final @NonNull 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.