StorageDomain.Preference


public final class StorageDomain.Preference extends StorageDomain


Targets on-device SharedPreferences XML files.

Summary

Public constructors

Preference(
    @NonNull String prefName,
    @NonNull String key,
    Object value,
    boolean isDeviceProtectedStorage
)

Public methods

boolean
equals(Object other)
final @NonNull String

The specific preference key to seed or verify.

final @NonNull String

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

final Object

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

int
final 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.

@NonNull String

Public constructors

Preference

Added in 1.0.0-alpha04
public Preference(
    @NonNull String prefName,
    @NonNull String key,
    Object value,
    boolean isDeviceProtectedStorage
)

Public methods

equals

public boolean equals(Object other)

getKey

Added in 1.0.0-alpha04
public final @NonNull String getKey()

The specific preference key to seed or verify.

getPrefName

Added in 1.0.0-alpha04
public final @NonNull String getPrefName()

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

getValue

Added in 1.0.0-alpha04
public final Object getValue()

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.

hashCode

public int hashCode()

isDeviceProtectedStorage

Added in 1.0.0-alpha04
public final boolean isDeviceProtectedStorage()

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.

toString

public @NonNull String toString()