android - Query last rows from parse.com table? -
i trying query last 20 rows parse.com table. have followed tutorial , generated code below. code returning 20 rows table not last 20 rows. returns first 20 items. how retrieve last 20 rows?
parsequery<parseobject> query = parsequery.getquery("activities"); query.setlimit(20); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> scorelist, parseexception e) { } });
it seems need different sort method on parsequery making. can order query results createddate field:
// sorts results in descending order created date field query.orderbydescending("datecreated");
so, in code, like:
//where "createddate", set name of created date field in table. parsequery<parseobject> query = parsequery.getquery("activities"); query.orderbydescending("createddate").setlimit(20); query.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> scorelist, parseexception e) { } });
in end, first 20 results, results ordered other way around, should work intended.
Comments
Post a Comment