java.lang.Object | |
↳ | com.kinvey.android.offline.OfflineAppData<T> |
This class allows for managing a collection while the client is offline, and syncing with Kinvey when a connection is restored.
The OfflineStore class maintains the latest state of all Entities, as well as a queue of all REST requests made while offline. When there are requests in the queue, an Android Service will be started to pull these requests and send them to Kinvey. This class provides offline storage for data, queueing up REST requests, executing those requests, and updating the offline store with results. NOTE while the offline data store is persistent, it will be empty when it is first created and needs to be seeded-- take this into consideration when designing an app to function offline. This initial seeding can happen by calling save on offlineAppDataPublic Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
OfflineAppData(String collectionName, Class myClass, AbstractClient client, Context context)
Constructor to instantiate the Offline AppData class.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
delete(String entityID, KinveyDeleteCallback callback)
Delete an entity from an offline collection.
| ||||||||||
void |
get(Query q, KinveyListCallback<T> callback)
Get entities by query from an offline collection.
| ||||||||||
void |
getEntity(String entityID, KinveyClientCallback<T> callback)
Get an entity or entities from an offline collection.
| ||||||||||
int |
getEntityCount()
Get how many entities are locally persisted to disk
| ||||||||||
List<OfflineRequestInfo> |
getFailedCalls()
Get a list of requests executed by the background executor which failed.
| ||||||||||
int |
getQueueSize()
Get how many requests are queued up for execution when a connection is restored.
| ||||||||||
List<OfflineRequestInfo> |
getSuccessfulCalls()
Get a list of requests executed by the background executor which were successful.
| ||||||||||
OfflineSettings |
offlineSettings()
Gets the instance of the OfflineSettings singleotn class
| ||||||||||
void |
save(T entity, KinveyClientCallback<T> callback)
Save (create or update) an entity to an offline collection.
| ||||||||||
void |
setCallback(KinveySyncCallback callback)
Set a callback to retrieve updates on live execution of requests in background
| ||||||||||
static void |
startSync(Context context)
Start the OfflineAppDataService with an intent for performing Sync
| ||||||||||
void |
update(Observable observable, Object o)
Called by the
com.kinvey.android.offline.OfflineStore when an update occurs. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Constructor to instantiate the Offline AppData class.
collectionName | Name of the appData collection |
---|---|
myClass | Class Type to marshall data between. |
Delete an entity from an offline collection.
entityID | entityID to delete |
---|
IOException |
---|
Get entities by query from an offline collection.
Get an entity or entities from an offline collection. Pass null to entityID to return all entities in a collection.
entityID | entityID to get |
---|
IOException |
---|
Get how many entities are locally persisted to disk
Get a list of requests executed by the background executor which failed.
Get how many requests are queued up for execution when a connection is restored.
Get a list of requests executed by the background executor which were successful.
Gets the instance of the OfflineSettings singleotn class
Save (create or update) an entity to an offline collection.
entity | Entity to Save |
---|
IOException |
---|
Set a callback to retrieve updates on live execution of requests in background
callback | instance of a callback to receive updates. |
---|
Start the OfflineAppDataService with an intent for performing Sync
Called by the com.kinvey.android.offline.OfflineStore
when an update occurs.
observable | - the Offline Store |
---|---|
o | - the Request Info of the update. |