public class GRexPersister
extends java.lang.Object
| Constructor and Description |
|---|
GRexPersister(android.content.Context context,
java.lang.String dirName)
Create a new instance.
|
GRexPersister(android.content.Context context,
java.lang.String dirName,
Gson gson)
Create a new instances using a provided Gson.
|
| Modifier and Type | Method and Description |
|---|---|
<T> |
addToList(java.lang.String key,
T object,
java.lang.Class<T> type)
Adds an object to an existing List, or creates and stores a new List.
|
|
clear(java.lang.String key)
Clears any data stored at the specified key.
|
<T> |
get(java.lang.String key,
java.lang.Class<T> type)
Retrieves an object from disk.
|
<T> |
getList(java.lang.String key,
java.lang.Class<T> type)
Reads a List of objects from disk.
|
<T> |
put(java.lang.String key,
T object)
Writes an object to disk.
|
<T> |
putList(java.lang.String key,
java.util.List<T> list,
java.lang.Class<T> type)
Write a List of objects to disk.
|
<T> |
removeFromList(java.lang.String key,
int position,
java.lang.Class<T> type)
Remove an object from an existing List by its index.
|
<T> |
removeFromList(java.lang.String key,
T object,
java.lang.Class<T> type)
Remove an object from an existing List.
|
public GRexPersister(android.content.Context context,
java.lang.String dirName)
context - Context used to determine file directory.dirName - The sub directory name to perform all read/write operations to.public GRexPersister(android.content.Context context,
java.lang.String dirName,
Gson gson)
context - Context used to determine file directory.dirName - The sub directory name to perform all read/write operations to.gson - Gson used to serialize/deserialize objects.public <T>putList(java.lang.String key, java.util.List<T> list, java.lang.Class<T> type)
key - The key to store the List against.list - The List to store.type - The class of each item stored in the List.public <T>getList(java.lang.String key, java.lang.Class<T> type)
key - The key that the List is stored against.type - The type of each item stored in the List.public <T>addToList(java.lang.String key, T object, java.lang.Class<T> type)
key - The key that the List is stored against. (Or will be stored against if its
currently empty).object - The object to add to the List.type - The type of each item in the List.public <T>removeFromList(java.lang.String key, T object, java.lang.Class<T> type)
key - The key that the List is stored against.object - The object to remove from the List.type - The type of each item stored in the List.public <T>removeFromList(java.lang.String key, int position, java.lang.Class<T> type)
key - The key that the List is stored against.position - The index of the item to remove.type - The type of each item stored in the List.public <T>put(java.lang.String key, T object)
key - The key to store the object against.object - The object to write to disk.public <T>get(java.lang.String key, java.lang.Class<T> type)
key - The key that the object is stored against.type - The type of the object stored on disk.publicclear(java.lang.String key)
key - The key to clear data at.