public interface SharedPreferencesCache
SharedPreferences
in a memory.| Modifier and Type | Interface and Description |
|---|---|
static class |
SharedPreferencesCache.NotInCacheException
An exception that may be used by implementations of
SharedPreferencesCache to indicate
that they have no value stored for a requested key. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(String key)
Checks whether there is stored value for the specified key in this cache.
|
boolean |
evict(String key)
Evicts a value for the specified key stored in this cache.
|
int |
evictAll()
Evicts all values stored in this cache.
|
boolean |
getBoolean(String key)
Retrieves the boolean value for the specified key stored in this cache.
|
float |
getFloat(String key)
Retrieves the float value for the specified key stored in this cache.
|
int |
getInt(String key)
Retrieves the integer value for the specified key stored in this cache.
|
long |
getLong(String key)
Retrieves the long value for the specified key stored in this cache.
|
String |
getString(String key)
Retrieves the string value for the specified key stored in this cache.
|
Set<String> |
getStringSet(String key)
Retrieves the set of string values for the specified key stored in this cache.
|
boolean |
isEmpty()
Checks whether this cache is empty or not.
|
boolean |
putBoolean(String key,
boolean value)
Puts the given boolean value for the specified key into this cache.
|
boolean |
putFloat(String key,
float value)
Puts the given float value for the specified key into this cache.
|
boolean |
putInt(String key,
int value)
Puts the given integer value for the specified key into this cache.
|
boolean |
putLong(String key,
long value)
Puts the given long value for the specified key into this cache.
|
boolean |
putString(String key,
String value)
Puts the given string value for the specified key into this cache.
|
boolean |
putStringSet(String key,
Set<String> values)
Puts the given set of string values for the specified key into this cache.
|
boolean isEmpty()
True if this cache does not have any values stored, false if there
is at least one value stored.boolean contains(@NonNull
String key)
key - The key of which value presence to check.True if there is value presented for the specified key, false otherwise.boolean putString(@NonNull
String key,
@Nullable
String value)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.value - The desired value to put into cache.True if put has been successful, false otherwise.@Nullable String getString(@NonNull String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean putStringSet(@NonNull
String key,
@Nullable
Set<String> values)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.values - The desired set of values to put into cache.True if put has been successful, false otherwise.@Nullable Set<String> getStringSet(@NonNull String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean putInt(@NonNull
String key,
int value)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.value - The desired value to put into cache.True if put has been successful, false otherwise.int getInt(@NonNull
String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean putFloat(@NonNull
String key,
float value)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.value - The desired value to put into cache.True if put has been successful, false otherwise.float getFloat(@NonNull
String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean putLong(@NonNull
String key,
long value)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.value - The desired value to put into cache.True if put has been successful, false otherwise.long getLong(@NonNull
String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean putBoolean(@NonNull
String key,
boolean value)
If there is already stored value for the specified key in this cache it will be replaced by the new one.
key - The key for which to put the value into cache.value - The desired value to put into cache.True if put has been successful, false otherwise.boolean getBoolean(@NonNull
String key)
key - The key for which to retrieve its associated value.SharedPreferencesCache.NotInCacheException - If there is no value stored in this cache for the requested key.contains(String)boolean evict(@NonNull
String key)
key - The key for which to evict its associated value.True if value associated with the key has been evicted, false if there
was no value stored in this cache for the specified key.int evictAll()
0 if this cache is empty.