Check whether local datastore is empty

516 views Asked by At

I am learning to build android app using Parse. I need to check if Parse local datastore is empty, i.e there are currently no pinned objects on the datastore.

Is there a simple way to do it ?

2

There are 2 answers

0
Björn Kaiser On BEST ANSWER

There is. Query the local datastore and check if the number of returned objects == 0

0
Chau Thai On

The fast and simple way to do it is:

public boolean isEmpty(String className) {
     ParseQuery<ParseObject> query = ParseQuery.getQuery(className);
     query.fromLocalDatastore();
     return query.count() == 0;
}

This only works for checking single class.