SharedPreferencesView
class SharedPreferencesView
Read-only wrapper around SharedPreferences. This will be passed in to your migration.
Summary
Public functions |
|
|---|---|
operator Boolean |
Checks whether the preferences contains a preference. |
Map<String, Any?> |
getAll()Retrieve all values from the preferences that are in the specified keySet. |
Boolean |
getBoolean(key: String, defValue: Boolean)Retrieves a boolean value from the preferences. |
Float |
Retrieves a float value from the preferences. |
Int |
Retrieves a int value from the preferences. |
Long |
Retrieves a long value from the preferences. |
String? |
Retrieves a string value from the preferences. |
Set<String>? |
getStringSet(key: String, defValues: Set<String>?)Retrieves a string set value from the preferences. |
Public functions
contains
operator fun contains(key: String): Boolean
Checks whether the preferences contains a preference.
| Parameters | |
|---|---|
key: String |
the name of the preference to check |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getAll
fun getAll(): Map<String, Any?>
Retrieve all values from the preferences that are in the specified keySet.
getBoolean
fun getBoolean(key: String, defValue: Boolean): Boolean
Retrieves a boolean value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValue: Boolean |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getFloat
fun getFloat(key: String, defValue: Float): Float
Retrieves a float value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValue: Float |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getInt
fun getInt(key: String, defValue: Int): Int
Retrieves a int value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValue: Int |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getLong
fun getLong(key: String, defValue: Long): Long
Retrieves a long value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValue: Long |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getString
fun getString(key: String, defValue: String? = null): String?
Retrieves a string value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValue: String? = null |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |
getStringSet
fun getStringSet(key: String, defValues: Set<String>? = null): Set<String>?
Retrieves a string set value from the preferences.
| Parameters | |
|---|---|
key: String |
the name of the preference to retrieve |
defValues: Set<String>? = null |
value to return if this preference does not exist |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if |