public class IsolatedKeyValueStore extends java.lang.Object implements IKeyValueStorage
storeName
at any one time, and all Thread safety must be managed by the calling code.Constructor and Description |
---|
IsolatedKeyValueStore(java.lang.String storeName)
Create a named Key-Value store.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addValue(java.lang.String key,
java.lang.String value)
Add a key-value pair to the store.
|
boolean |
clear()
Wipe the entire store, removing all key-value pairs.
|
java.lang.String[] |
getAllKeys()
Get a
String array of all keys in this store. |
java.lang.String |
getValue(java.lang.String key)
Gets a value associated with a
key . |
java.lang.String |
getValue(java.lang.String key,
java.lang.String defaultValue)
Gets a value associated with a
key . |
static boolean |
isStoreSupported()
Determine if this class is supported with this combination of device, platform and OS version.
|
boolean |
removeValue(java.lang.String key)
Remove a key-value pair from the store altogether.
|
public IsolatedKeyValueStore(java.lang.String storeName)
storeName
- The name of the store to use.java.lang.NullPointerException
- if the storeName
is null.java.lang.IllegalArgumentException
- if the storeName
is not appropriate for this platform (so at a minimum the empty String, "", will do this on all platforms.)public static boolean isStoreSupported()
true
if the class is supported, false
otherwise.public boolean addValue(java.lang.String key, java.lang.String value)
addValue
in interface IKeyValueStorage
key
- The identifying key to associate with the value.value
- The value to set.true
if the value is correctly set.java.lang.NullPointerException
- if the key
is null.public java.lang.String getValue(java.lang.String key)
key
.getValue
in interface IKeyValueStorage
null
if no value can be found.java.lang.NullPointerException
- if the key
is null.public java.lang.String getValue(java.lang.String key, java.lang.String defaultValue)
key
.getValue
in interface IKeyValueStorage
defaultValue
if no value can be found.java.lang.NullPointerException
- if the key
is null.public boolean removeValue(java.lang.String key)
removeValue
in interface IKeyValueStorage
true
if the operation is successful.java.lang.NullPointerException
- if the key
is null.public boolean clear()
clear
in interface IKeyValueStorage
true
if successful.public java.lang.String[] getAllKeys()
String
array of all keys in this store.getAllKeys
in interface IKeyValueStorage