android-components / mozilla.components.support.base.utils / SharedPreferencesCache

SharedPreferencesCache

abstract class SharedPreferencesCache<T> (source)

An abstract wrapper around SharedPreferences which facilitates caching of T objects.

Constructors

Name Summary
<init> SharedPreferencesCache(context: <ERROR CLASS>)
An abstract wrapper around SharedPreferences which facilitates caching of T objects.

Properties

Name Summary
cacheKey abstract val cacheKey: String
Name of the ‘key’ under which serialized data is stored within the cache.
cacheName abstract val cacheName: String
Name of the cache.
context val context: <ERROR CLASS>
logger abstract val logger: Logger
Logger used to report issues.

Functions

Name Summary
clear fun clear(): Unit
Clear cached values.
fromJSON abstract fun fromJSON(obj: <ERROR CLASS>): T
A conversion method from JSONObject to T.
getCached fun getCached(): T?
setToCache fun setToCache(obj: T): Unit
toJSON abstract fun T.toJSON(): <ERROR CLASS>
A conversion method from T into a JSONObject.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.

Inheritors

Name Summary
FxaDeviceSettingsCache class FxaDeviceSettingsCache : SharedPreferencesCache<DeviceSettings>
A thin wrapper around SharedPreferences which knows how to serialize/deserialize DeviceSettings.
SyncAuthInfoCache class SyncAuthInfoCache : SharedPreferencesCache<SyncAuthInfo>
A thin wrapper around SharedPreferences which knows how to serialize/deserialize SyncAuthInfo.