Check whether local datastore is empty

555 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 best solutions below

0
On BEST ANSWER

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

0
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.