How to retrieve more than 1000 rows from Parse.com?

前端 未结 10 1045
独厮守ぢ
独厮守ぢ 2020-11-29 19:54

I have been using Parse to retrieve a data for a list view. Unfortunately they limit requests to 100 by default to a 1000 max. I have well over that 1000 max in my class. I

10条回答
  •  感动是毒
    2020-11-29 20:48

    I have figured out how to achieve my goal:

    Declare Global Variable

    private static ListallObjects = new ArrayList();
    

    Create Query

    final ParseQuery parseQuery = new ParseQuery("Objects");
    parseQuery.setLimit(1000);
    parseQuery.findInBackground(getAllObjects());
    

    Callback for Query

    int skip=0;
    FindCallback getAllObjects(){
        return new FindCallback(){
            public void done(List objects, ParseException e) {
                if (e == null) {
    
                    allObjects.addAll(objects);
                     int limit =1000;
                    if (objects.size() == limit){
                        skip = skip + limit;
                        ParseQuery query = new ParseQuery("Objects");
                        query.setSkip(skip);
                        query.setLimit(limit);
                        query.findInBackground(getAllObjects());
                    }
                    //We have a full PokeDex
                    else {
                        //USE FULL DATA AS INTENDED
                    }
            }
        };
    }
    

提交回复
热议问题