public interface DataStore
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Begin a transaction.
|
void |
cancelTransaction()
Drop modifications which are applied in the current transaction.
|
void |
clear()
clear all.
|
boolean |
contains(java.lang.String key)
Returns if this data store has a value which is associated to a given key
|
void |
destroySelf()
destroy a file.
|
boolean |
finishTransaction(boolean commit)
Finish the current transaction successfully
|
java.util.Map<java.lang.String,?> |
getAll()
Returns all pairs of key and value which are stored.
|
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Obtain a boolean String value from this data store.
|
float |
getFloat(java.lang.String key,
float defaultValue)
Obtain a float value from this data store.
|
int |
getInt(java.lang.String key,
int defaultValue)
Obtain an int value from this data store.
|
long |
getLong(java.lang.String key,
long defaultValue)
Obtain a long value from this data store.
|
java.lang.String |
getNonNullString(java.lang.String key,
java.lang.String defaultValue)
Obtain a non-null
String value from this data store. |
java.util.Set<java.lang.String> |
getNonNullStringSet(java.lang.String key,
java.util.Set<java.lang.String> defaultValue)
Obtain a nonnull
Set of String value from this data store. |
java.lang.String |
getNullableString(java.lang.String key,
java.lang.String defaultValue)
Obtain a nullable
String value from this data store. |
java.util.Set<java.lang.String> |
getNullableStringSet(java.lang.String key,
java.util.Set<java.lang.String> defaultValue)
Obtain a nullable
Set of String value from this data store. |
boolean |
isDestroyed()
whether or not
destroySelf() is called. |
boolean |
isInTransaction()
Whether or not this data store is in a transaction
|
void |
setBoolean(java.lang.String key,
boolean value)
Set a boolean value to this data store immediately.
|
void |
setFloat(java.lang.String key,
float value)
Set a float value to this data store immediately.
|
void |
setInt(java.lang.String key,
int value)
Set an int value to this data store immediately.
|
void |
setLong(java.lang.String key,
long value)
Set a long value to this data store immediately.
|
void |
setNonNullString(java.lang.String key,
java.lang.String value)
Set a nonnull String value to this data store immediately.
|
void |
setNonNullStringSet(java.lang.String key,
java.util.Set<java.lang.String> value)
Set a nullable Set of String value to this data store immediately.
|
void |
setNullableString(java.lang.String key,
java.lang.String value)
Set a nullable String value to this data store immediately.
|
void |
setNullableStringSet(java.lang.String key,
java.util.Set<java.lang.String> value)
Set a nullable Set of String value to this data store immediately.
|
@NonNull java.util.Map<java.lang.String,?> getAll()
SharedPreferences.getAll()boolean contains(@NonNull
java.lang.String key)
key - a name of this data store to obtainSharedPreferences.contains(String)@Nullable
java.lang.String getNullableString(@NonNull
java.lang.String key,
@Nullable
java.lang.String defaultValue)
String value from this data store.
This may throw ClassCastException if an associated value is not an instance of String except nullkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.@NonNull
java.lang.String getNonNullString(@NonNull
java.lang.String key,
@NonNull
java.lang.String defaultValue)
String value from this data store.
This may throw ClassCastException if an associated value is not an instance of String except nullkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.@Nullable
java.util.Set<java.lang.String> getNullableStringSet(@NonNull
java.lang.String key,
@Nullable
java.util.Set<java.lang.String> defaultValue)
Set of String value from this data store.
This may throw ClassCastException if an associated value is not an instance of Set<String> except nullkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.@NonNull
java.util.Set<java.lang.String> getNonNullStringSet(@NonNull
java.lang.String key,
@NonNull
java.util.Set<java.lang.String> defaultValue)
Set of String value from this data store.
This may throw ClassCastException if an associated value is not an instance of Set<String> except nullkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.int getInt(@NonNull
java.lang.String key,
int defaultValue)
ClassCastException if an associated value is not an instance of intkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.long getLong(@NonNull
java.lang.String key,
long defaultValue)
ClassCastException if an associated value is not an instance of longkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.float getFloat(@NonNull
java.lang.String key,
float defaultValue)
ClassCastException if an associated value is not an instance of floatkey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.boolean getBoolean(@NonNull
java.lang.String key,
boolean defaultValue)
ClassCastException if an associated value is not an instance of booleankey - a name of this data store to obtaindefaultValue - to be returned if a key doesn't have a non-null value.void setNullableString(@NonNull
java.lang.String key,
@Nullable
java.lang.String value)
key - a name of this data store to obtainvalue - to be setvoid setNonNullString(@NonNull
java.lang.String key,
@NonNull
java.lang.String value)
key - a name of this data store to obtainvalue - to be setvoid setNullableStringSet(@NonNull
java.lang.String key,
@Nullable
java.util.Set<java.lang.String> value)
key - a name of this data store to obtainvalue - to be setvoid setNonNullStringSet(@NonNull
java.lang.String key,
@NonNull
java.util.Set<java.lang.String> value)
key - a name of this data store to obtainvalue - to be setvoid setInt(@NonNull
java.lang.String key,
int value)
key - a name of this data store to obtainvalue - to be setvoid setLong(@NonNull
java.lang.String key,
long value)
key - a name of this data store to obtainvalue - to be setvoid setFloat(@NonNull
java.lang.String key,
float value)
key - a name of this data store to obtainvalue - to be setvoid setBoolean(@NonNull
java.lang.String key,
boolean value)
key - a name of this data store to obtainvalue - to be setvoid beginTransaction()
finishTransaction(boolean),
cancelTransaction()boolean finishTransaction(boolean commit)
commit - whether do use SharedPreferences.Editor#commit() or notvoid cancelTransaction()
boolean isInTransaction()
void clear()
void destroySelf()
boolean isDestroyed()
destroySelf() is called.