Start a new topic

How do I count the number of accessable entities in a collection?

I've tried using appdata.countBlocking(new ArrayList(), null).



I don't want to download all the entities because it takes too long.

Basically I'm trying to do a SQL COUNT(*)
This bit of code:

ArrayList list = new ArrayList();

AsyncAppData.Aggregate res = entries.countBlocking(list, null);

Log.d(LOGTAG, "Amount of entries:"+res.toString());

is printing out

Amount of entries:{appKey=kid_Ve_dVjLrYi, collectionName=entries}

I think I have this solved, I was not using .execute() -- please see the following link for a helpful tutorial:

http://www.zunisoft.com/2013/08/kinvey-simple-aggregates.html
That said -- this very simple functionality should definitely be on the guide.
Actually, problem not solved.



countBlocking sometimes returns a count of 1 and sometimes returns the correct count. Normally on the first call after login it is returning 1.



EDIT: This problem was solved -- I just am querying an incorrect data set due to other issues I've brought up in another question.



If you are looking to count the entities in your collection, look no further than:

http://www.zunisoft.com/2013/08/kinvey-simple-aggregates.html
Hi James,

Glad you got it solved! You have a good point that including this in our guide would be helpful!
Login or Signup to post a comment