java.lang.Object | ||
↳ | java.util.Observable | |
↳ | com.kinvey.android.offline.OfflineStore<T> |
OfflineStore class.
The instance can be accessed through OfflineStore.getInstance(). It maintains both the latest state of all entities as well as a queue of REST requests made while offline.
The store persists to disk, and this class provides methods to force reading and writing.This class does two things:
store a copy of the local state of data and queue REST requests for later online execution.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
T |
GetEntityFromDataStore(String id)
returns an entity directly from the datastore
| ||||||||||
void | addQuery(Query query, String querystring, List<String> ids) | ||||||||||
void |
addToQueue(String httpVerb, String entityID)
put an entity directly in the request queue for later execution.
| ||||||||||
void |
addToQueue(String httpVerb, Query query, String queryjson)
put an entity directly in the request queue for later execution.
| ||||||||||
void |
addToStore(String entityID, T toAdd)
put an entity directly in the data store.
| ||||||||||
void |
delete(String entityID, KinveyDeleteCallback callback)
Queue a DELETE request for execution.
| ||||||||||
void | get(Query q, String jsonQuery, KinveyListCallback callback) | ||||||||||
void |
getEntity(String entityID, KinveyClientCallback callback)
Queue a GET request for execution.
| ||||||||||
int | getEntityStoreCount() | ||||||||||
ArrayList<OfflineRequestInfo> | getFailedCalls() | ||||||||||
Class | getMyClass() | ||||||||||
int | getRequestStoreCount() | ||||||||||
OfflineSettings | getSettings() | ||||||||||
static OfflineStore | getStore(Context context, String collectionName, Class myClass) | ||||||||||
static OfflineStore | getStore(Context context, String collectionName) | ||||||||||
ArrayList<OfflineRequestInfo> | getSuccessfulCalls() | ||||||||||
void | notifyExecution(String collection, boolean success, OfflineRequestInfo info, Object response) | ||||||||||
OfflineRequestInfo |
pop()
This method return the RequestInfo instance at the top of the queue.
| ||||||||||
void |
save(T entity, KinveyClientCallback callback)
Queue a PUT request for execution.
| ||||||||||
void | setMyClass(Class myClass) | ||||||||||
void | setSettings(OfflineSettings settings) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
returns an entity directly from the datastore
id | - the unique id of the entity |
---|
null
put an entity directly in the request queue for later execution.
This method will notify all observers.
httpVerb | - The verb of the pending request. |
---|---|
entityID | - the ID of the entity to apply this verb too |
put an entity directly in the request queue for later execution.
This method will notify all observers.
httpVerb | - The verb of the pending request. |
---|---|
query | - a query to execute |
put an entity directly in the data store.
This method will notify all observers.
entityID | - the unique id is used as a key |
---|---|
toAdd | - the entity to put in the store. |
Queue a DELETE request for execution. The callback onSuccess() indicates successful removal from the offline store. The callback onFailure() indicated failed removal from the offline store. The DELETE request is then queued for execution when a connection is restored.
entityID | - the ID entity to delete |
---|---|
callback | - Used to indicate result of offline storage (not online execution). |
Queue a GET request for execution. The callback onSuccess() indicates successful retrieval from the offline store. The callback onFailure() indicated failed retrieval from the offline store. The GET request is then queued for execution when a connection is restored.
entityID | - the unique ID of the entity to retrieve |
---|---|
callback | - Used to indicate result of offline storage (not online execution). |
This method return the RequestInfo instance at the top of the queue.
null
if empty.
Queue a PUT request for execution. The callback onSuccess() indicates successful insertion into the offline store. The callback onFailure() indicated failed insertion into the offline store. The PUT request is then queued for execution when a connection is restored.
entity | - the entity to put in the offline store |
---|---|
callback | - Used to indicate result of offline storage (not online execution). |