StorageDomain.Preference


class StorageDomain.Preference : StorageDomain


Targets on-device SharedPreferences XML files.

Summary

Public constructors

Preference(
    prefName: String,
    key: String,
    value: Any?,
    isDeviceProtectedStorage: Boolean
)

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

Boolean

Whether the SharedPreferences file is in device-protected storage, which is available before the user first unlocks the device, rather than in the default storage of the app.

String

The specific preference key to seed or verify.

String

The name of the SharedPreferences XML file (excluding the .xml extension).

Any?

The value associated with the preference key, or null if asserting missing state.

Public constructors

Preference

Added in 1.0.0-alpha04
Preference(
    prefName: String,
    key: String,
    value: Any? = null,
    isDeviceProtectedStorage: Boolean = false
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

isDeviceProtectedStorage

Added in 1.0.0-alpha04
val isDeviceProtectedStorage: Boolean

Whether the SharedPreferences file is in device-protected storage, which is available before the user first unlocks the device, rather than in the default storage of the app. That is credential-encrypted storage, unless the app sets android:defaultToDeviceProtectedStorage.

key

Added in 1.0.0-alpha04
val key: String

The specific preference key to seed or verify.

prefName

Added in 1.0.0-alpha04
val prefName: String

The name of the SharedPreferences XML file (excluding the .xml extension).

value

Added in 1.0.0-alpha04
val value: Any?

The value associated with the preference key, or null if asserting missing state. Supported types are: String, Int, Long, Float, Boolean, a Set of Strings, or null; other types fail construction with an IllegalArgumentException. A set is stored with putStringSet and compared regardless of the order of its elements; the preference keeps a copy of it. A null value is seeded by removing the key and verified by checking that the key is absent. Clearing app data also removes the key, so a null value cannot detect a restore that loses data.