SharedPreferencesView
public final class SharedPreferencesView
Read-only wrapper around SharedPreferences. This will be passed in to your migration.
Summary
Public methods |
|
|---|---|
final boolean |
Checks whether the preferences contains a preference. |
final @NonNull Map<@NonNull String, Object> |
getAll()Retrieve all values from the preferences that are in the specified keySet. |
final boolean |
getBoolean(@NonNull String key, boolean defValue)Retrieves a boolean value from the preferences. |
final float |
Retrieves a float value from the preferences. |
final int |
Retrieves a int value from the preferences. |
final long |
Retrieves a long value from the preferences. |
final String |
Retrieves a string value from the preferences. |
final Set<@NonNull String> |
Retrieves a string set value from the preferences. |
Public methods
contains
public final boolean contains(@NonNull String key)
Checks whether the preferences contains a preference.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getAll
public final @NonNull Map<@NonNull String, Object> getAll()
Retrieve all values from the preferences that are in the specified keySet.
getBoolean
public final boolean getBoolean(@NonNull String key, boolean defValue)
Retrieves a boolean value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
boolean defValue |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getFloat
public final float getFloat(@NonNull String key, float defValue)
Retrieves a float value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
float defValue |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getInt
public final int getInt(@NonNull String key, int defValue)
Retrieves a int value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
int defValue |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getLong
public final long getLong(@NonNull String key, long defValue)
Retrieves a long value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
long defValue |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getString
public final String getString(@NonNull String key, String defValue)
Retrieves a string value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
String defValue |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getStringSet
public final Set<@NonNull String> getStringSet(@NonNull String key, Set<@NonNull String> defValues)
Retrieves a string set value from the preferences.
| Parameters | |
|---|---|
@NonNull String key |
the name of the preference to retrieve |
Set<@NonNull String> defValues |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |