public class

OfflineStore

extends Observable
java.lang.Object
   ↳ java.util.Observable
     ↳ com.kinvey.android.offline.OfflineStore<T>

Class Overview

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.

Summary

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
From class java.util.Observable
From class java.lang.Object

Public Methods

public T GetEntityFromDataStore (String id)

returns an entity directly from the datastore

Parameters
id - the unique id of the entity
Returns
  • the entity OR null

public void addQuery (Query query, String querystring, List<String> ids)

public void addToQueue (String httpVerb, String entityID)

put an entity directly in the request queue for later execution.

This method will notify all observers.

Parameters
httpVerb - The verb of the pending request.
entityID - the ID of the entity to apply this verb too

public void addToQueue (String httpVerb, Query query, String queryjson)

put an entity directly in the request queue for later execution.

This method will notify all observers.

Parameters
httpVerb - The verb of the pending request.
query - a query to execute

public void addToStore (String entityID, T toAdd)

put an entity directly in the data store.

This method will notify all observers.

Parameters
entityID - the unique id is used as a key
toAdd - the entity to put in the store.

public void delete (String entityID, KinveyDeleteCallback callback)

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.

Parameters
entityID - the ID entity to delete
callback - Used to indicate result of offline storage (not online execution).

public void get (Query q, String jsonQuery, KinveyListCallback callback)

public void getEntity (String entityID, KinveyClientCallback callback)

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.

Parameters
entityID - the unique ID of the entity to retrieve
callback - Used to indicate result of offline storage (not online execution).

public int getEntityStoreCount ()

public ArrayList<OfflineRequestInfo> getFailedCalls ()

public Class getMyClass ()

public int getRequestStoreCount ()

public OfflineSettings getSettings ()

public static OfflineStore getStore (Context context, String collectionName, Class myClass)

public static OfflineStore getStore (Context context, String collectionName)

public ArrayList<OfflineRequestInfo> getSuccessfulCalls ()

public void notifyExecution (String collection, boolean success, OfflineRequestInfo info, Object response)

public OfflineRequestInfo pop ()

This method return the RequestInfo instance at the top of the queue.

Returns
  • information about the first client request that has been queued OR null if empty.

public void save (T entity, KinveyClientCallback callback)

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.

Parameters
entity - the entity to put in the offline store
callback - Used to indicate result of offline storage (not online execution).

public void setMyClass (Class myClass)

public void setSettings (OfflineSettings settings)