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<StringAny?>

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
getFloat(key: String, defValue: Float)

Retrieves a float value from the preferences.

Int
getInt(key: String, defValue: Int)

Retrieves a int value from the preferences.

Long
getLong(key: String, defValue: Long)

Retrieves a long value from the preferences.

String?
getString(key: String, defValue: 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

Added in 1.0.0
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 key wasn't specified as part of this migration

getAll

Added in 1.0.0
fun getAll(): Map<StringAny?>

Retrieve all values from the preferences that are in the specified keySet.

getBoolean

Added in 1.0.0
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 key wasn't specified as part of this migration

getFloat

Added in 1.0.0
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 key wasn't specified as part of this migration

getInt

Added in 1.0.0
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 key wasn't specified as part of this migration

getLong

Added in 1.0.0
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 key wasn't specified as part of this migration

getString

Added in 1.0.0
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 key wasn't specified as part of this migration

getStringSet

Added in 1.0.0
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 key wasn't specified as part of this migration