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 addToQueue(String httpVerb, String entityID)
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(String entityID, KinveyClientCallback callback)
Queue a GET request for execution.
int getEntityStoreCount()
ArrayList<OfflineRequestInfo> getFailedCalls()
int getRequestStoreCount()
OfflineSettings getSettings()
ArrayList<OfflineRequestInfo> getSuccessfulCalls()
void notifyExecution(boolean success, OfflineRequestInfo info)
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 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 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 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 (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 int getRequestStoreCount ()

public OfflineSettings getSettings ()

public ArrayList<OfflineRequestInfo> getSuccessfulCalls ()

public void notifyExecution (boolean success, OfflineRequestInfo info)

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 setSettings (OfflineSettings settings)