Package-level declarations

Types

Link copied to clipboard

Representation possibilities for Double, because SharedPreferences don't have getDouble or putDouble methods.

Link copied to clipboard
sealed class Preferences : SerialFormat

Serializes and deserializes class properties into SharedPreferences consisting of string keys and primitive type values.

Link copied to clipboard

Builder of the Preferences instance provided by Preferences(sharedPreferences) { ... } factory function.

Functions

Link copied to clipboard
inline fun <T> Preferences.asProperty(tag: String? = null): ReadWriteProperty<Any?, T>
inline fun <T> Preferences.asProperty(tag: String? = null, default: T): ReadWriteProperty<Any?, T>
fun <T> Preferences.asProperty(serializer: KSerializer<T>, tag: String? = null): ReadWriteProperty<Any?, T>
fun <T> Preferences.asProperty(serializer: KSerializer<T>, tag: String? = null, default: T): ReadWriteProperty<Any?, T>

Encodes changes to the delegated property into the SharedPreferences and decodes the current value from them.

Link copied to clipboard
inline fun <T> Preferences.decode(tag: String): T

Decodes and deserializes from the SharedPreferences at the specified tag to the value of type T using deserializer retrieved from the reified type parameter.

Link copied to clipboard
inline fun <T> Preferences.decodeOrDefault(tag: String, default: T): T

Decodes and deserializes from the SharedPreferences at the specified tag to the value of type T using deserializer retrieved from the reified type parameter.

Link copied to clipboard
inline fun <T> Preferences.encode(tag: String, value: T)

Serializes and encodes the given value into the SharedPreferences at the specified tag using serializer retrieved from the reified type parameter.

Link copied to clipboard
fun Preferences(sharedPreferences: SharedPreferences, builderAction: PreferencesBuilder.() -> Unit = {}): Preferences

Creates an instance of Preferences encoding and decoding data from the given SharedPreferences and adjusted with builderAction.

fun Preferences(preferences: Preferences, builderAction: PreferencesBuilder.() -> Unit = {}): Preferences

Creates an instance of Preferences using the configuration of the previous created Preferences and adjusted with builderAction.