public class

AsyncAppData

extends AppData<T>
java.lang.Object
   ↳ com.kinvey.java.AppData<T>
     ↳ com.kinvey.android.AsyncAppData<T>

Class Overview

Wraps the com.kinvey.java.AppData public methods in asynchronous functionality using native Android AsyncTask.

This functionality can be accessed through the appData(String, Class) convenience method. AppData gets and saves entities that extend com.google.api.client.json.GenericJson. A class that extends GenericJson can map class members to KinveyCollection properties using com.google.api.client.util.Key attributes. For example, the following will map a string "city" to a Kinvey collection attributed named "city":

Summary

[Expand]
Inherited Constants
From class com.kinvey.java.AppData
Public Methods
void average(ArrayList<String> fields, String averageField, Query query, KinveyClientCallback callback)
Asynchronous request to retrieve a group by AVERAGE on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the average value of records based on a field or groups of fields.

void count(ArrayList<String> fields, Query query, KinveyClientCallback callback)
Asynchronous request to retrieve a group by COUNT on a collection or filtered collection.
void delete(Query query, KinveyDeleteCallback callback)
Asynchronous request to delete a collection of entites from a collection by Query.
void delete(String entityID, KinveyDeleteCallback callback)
Asynchronous request to delete an entity to a collection.
void get(Query query, KinveyListCallback<T> callback)
Asynchronous request to fetch an array of Entities using a Query object.
void get(KinveyListCallback<T> callback)
Asynchronous request to fetch an array of all Entities in a collection.
void getEntity(String entityID, KinveyClientCallback<T> callback)
Asynchronous request to fetch a single Entity by ID.
void max(ArrayList<String> fields, String maxField, Query query, KinveyClientCallback callback)
Asynchronous request to retrieve a group by MAX on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the max value of records based on a field or groups of fields.

void min(ArrayList<String> fields, String minField, Query query, KinveyClientCallback callback)
Asynchronous request to retrieve a group by MIN on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the min value of records based on a field or groups of fields.

void save(T entity, KinveyClientCallback<T> callback)
Asynchronous request to save or update an entity to a collection.
void sum(ArrayList<String> fields, String sumField, Query query, KinveyClientCallback callback)
Asynchronous request to retrieveBlocking a group by SUM on a collection or filtered collection

Generates an asynchronous request to group a collection and provide a sumBlocking of records based on a field or groups of fields.

[Expand]
Inherited Methods
From class com.kinvey.java.AppData
From class java.lang.Object

Public Methods

public void average (ArrayList<String> fields, String averageField, Query query, KinveyClientCallback callback)

Asynchronous request to retrieve a group by AVERAGE on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the average value of records based on a field or groups of fields. The aggregate will reduce an entire collection, or a collection filtered by a Query

Sample Usage:

        AppData aggregate = kinveyClient.appData("events", EventEntity.class");
        ArrayList fields = new ArrayList();
        fields.add("userName");
        aggregate.average(fields, "orderTotal", null, new KinveyClientCallback() {
            public void onSuccess(EventEntity event) { ... }
            public void onFailure(Throwable T) {...}
        });
 

Parameters
fields ArrayList of fields to aggregate on
averageField Field to get the maxBlocking value from
query Optional query object for filtering results to aggregate on. Set to null for entire collection.
callback KinveyClientCallback

public void count (ArrayList<String> fields, Query query, KinveyClientCallback callback)

Asynchronous request to retrieve a group by COUNT on a collection or filtered collection.

Generates an asynchronous request to group a collection and provide a count of records based on a field or groups of fields. The aggregate will reduce an entire collection, or a collection filtered by a Query

Sample Usage:

        AppData aggregate = kinveyClient.appData("events", EventEntity.class");
        ArrayList fields = new ArrayList();
        fields.add("userName");
        aggregate.count(fields, null, new KinveyClientCallback() {
            public void onSuccess(EventEntity event) { ... }
            public void onFailure(Throwable T) {...}
        });
 

Parameters
fields ArrayList of fields to aggregate on
query Optional query object for filtering results to aggregate on. Set to null for entire collection.
callback KinveyClientCallback

public void delete (Query query, KinveyDeleteCallback callback)

Asynchronous request to delete a collection of entites from a collection by Query.

Creates an asynchronous request to delete an entity from a collection by Entity ID. Uses KinveyDeleteCallback to return a com.kinvey.java.model.KinveyDeleteResponse.

Sample Usage:

        AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class);
         Query myQuery = new Query();
         myQuery.equals("age",21);
        myAppData.delete(myQuery, new KinveyDeleteCallback {
            public void onFailure(Throwable t) { ... }
            public void onSuccess(EventEntity[] entities) { ... }
        });
 

Parameters
query Query to filter the results.
callback KinveyDeleteCallback

public void delete (String entityID, KinveyDeleteCallback callback)

Asynchronous request to delete an entity to a collection.

Creates an asynchronous request to delete a group of entities from a collection based on a Query object. Uses KinveyDeleteCallback to return a com.kinvey.java.model.KinveyDeleteResponse. Queries can be constructed with Query. An empty Query object will delete all items in the collection.

Sample Usage:

        AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class);
        myAppData.delete(myQuery, new KinveyDeleteCallback {
            public void onFailure(Throwable t) { ... }
            public void onSuccess(EventEntity[] entities) { ... }
     });
 

Parameters
entityID the ID to delete
callback KinveyDeleteCallback

public void get (Query query, KinveyListCallback<T> callback)

Asynchronous request to fetch an array of Entities using a Query object.

Constructs an asynchronous request to fetch an Array of Entities, filtering by a Query object. Uses KinveyListCallback to return an Array of type T. Queries can be constructed with Query. An empty Query object will return all items in the collection.

Sample Usage:

        AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class);
        Query myQuery = new Query();
        myQuery.equals("age",21);
        myAppData.get(myQuery, new KinveyListCallback {
            public void onFailure(Throwable t) { ... }
            public void onSuccess(EventEntity[] entities) { ... }
        });
 

Parameters
query Query to filter the results.
callback KinveyListCallback

public void get (KinveyListCallback<T> callback)

Asynchronous request to fetch an array of all Entities in a collection.

Constructs an asynchronous request to fetch an Array of all entities in a collection. Uses KinveyListCallback to return an Array of type T.

Sample Usage:

         AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class);
         myAppData.get(new KinveyListCallback {
         public void onFailure(Throwable t) { ... }
         public void onSuccess(EventEntity[] entities) { ... }
         });
 

Parameters
callback KinveyListCallback

public void getEntity (String entityID, KinveyClientCallback<T> callback)

Asynchronous request to fetch a single Entity by ID.

Constructs an asynchronous request to fetch a single Entity by its Entity ID. Returns an instance of that Entity via KinveyClientCallback

Sample Usage:

        AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class).get("123",
                new KinveyClientCallback {
            public void onFailure(Throwable t) { ... }
            public void onSuccess(EventEntity entity) { ... }
        });
 

Parameters
entityID entityID to fetch
callback KinveyClientCallback

public void max (ArrayList<String> fields, String maxField, Query query, KinveyClientCallback callback)

Asynchronous request to retrieve a group by MAX on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the max value of records based on a field or groups of fields. The aggregate will reduce an entire collection, or a collection filtered by a Query

Sample Usage:

        AppData aggregate = kinveyClient.appData("events", EventEntity.class");
        ArrayList fields = new ArrayList();
        fields.add("userName");
        aggregate.max(fields, "orderTotal", null, new KinveyClientCallback() {
             public void onSuccess(EventEntity event) { ... }
             public void onFailure(Throwable T) {...}
        });
 

Parameters
fields ArrayList of fields to aggregate on
maxField Field to get the max value from
query Optional query object for filtering results to aggregate on. Set to null for entire collection.
callback KinveyClientCallback

public void min (ArrayList<String> fields, String minField, Query query, KinveyClientCallback callback)

Asynchronous request to retrieve a group by MIN on a collection or filtered collection

Generates an asynchronous request to group a collection and provide the min value of records based on a field or groups of fields. The aggregate will reduce an entire collection, or a collection filtered by a Query

Sample Usage:

        AppData aggregate = kinveyClient.appData("events", EventEntity.class");
        ArrayList fields = new ArrayList();
        fields.add("userName");
        aggregate.min(fields, "orderTotal", null, new KinveyClientCallback() {
            public void onSuccess(EventEntity event) { ... }
            public void onFailure(Throwable T) {...}
        });
 

Parameters
fields ArrayList of fields to aggregate on
minField Field to get the min value from
query Optional query object for filtering results to aggregate on. Set to null for entire collection.
callback KinveyClientCallback

public void save (T entity, KinveyClientCallback<T> callback)

Asynchronous request to save or update an entity to a collection.

Constructs an asynchronous request to save an entity of type T to a collection. Creates the entity if it doesn't exist, updates it if it does exist. If an "_id" property is not present, the Kinvey backend will generate one.

Sample Usage:

         AppData myAppData = kinveyClient.appData("myCollection", EventEntity.class);
         myAppData.save(entityID, new KinveyClientCallback {
             public void onFailure(Throwable t) { ... }
             public void onSuccess(EventEntity[] entities) { ... }
         });
 

Parameters
entity The entity to save
callback KinveyClientCallback

public void sum (ArrayList<String> fields, String sumField, Query query, KinveyClientCallback callback)

Asynchronous request to retrieveBlocking a group by SUM on a collection or filtered collection

Generates an asynchronous request to group a collection and provide a sumBlocking of records based on a field or groups of fields. The aggregate will reduce an entire collection, or a collection filtered by a Query

Sample Usage:

        AppData aggregate = kinveyClient.appData("events", EventEntity.class");
        ArrayList fields = new ArrayList();
        fields.add("userName");
        aggregate.sumBlocking(fields, "orderTotal", null, new KinveyClientCallback() {
            public void onSuccess(EventEntity event) { ... }
            public void onFailure(Throwable T) {...}
        });
 

Parameters
fields ArrayList of fields to aggregate on
sumField Field to sumBlocking
query Optional query object for filtering results to aggregate on. Set to null for entire collection.
callback KinveyClientCallback