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 StringObject>

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
getFloat(@NonNull String key, float defValue)

Retrieves a float value from the preferences.

final int
getInt(@NonNull String key, int defValue)

Retrieves a int value from the preferences.

final long
getLong(@NonNull String key, long defValue)

Retrieves a long value from the preferences.

final String
getString(@NonNull String key, String defValue)

Retrieves a string value from the preferences.

final Set<@NonNull String>

Retrieves a string set value from the preferences.

Public methods

contains

Added in 1.0.0
public final boolean contains(@NonNull String key)

Checks whether the preferences contains a preference.

Parameters
@NonNull String key

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
public final @NonNull Map<@NonNull StringObjectgetAll()

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

getBoolean

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

getFloat

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

getInt

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

getLong

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

getString

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

getStringSet

Added in 1.0.0
public final Set<@NonNull StringgetStringSet(@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 key wasn't specified as part of this migration