get

fun <T : Any> get(key: String, defaultValue: T): T

Retrieves the value associated with the given key from SharedPreferences. If the key is not found, the default value is returned.

The value's type should be one of the following: String, Set, Boolean, Float, or Long.

Return

The value associated with the given key, or the default value if the key is not found.

Parameters

key

The key to retrieve the value for.

defaultValue

The default value to return if the key is not found.

See also

Throws

if the default value is not one of the supported types.