How to retrieve data from all pages?

I want to get some data from all users in Users table. I’ve found that I have to use Data paging. I’ve written the same code as described in Feature 47->https://backendless.com/feature-47-loading-data-objects-from-server-with-sorting/ (because I also have to sort) , but then I’ve figured out that this code takes data only from first page. Then , I decided that I have to go to the next page and read it , until its size is not equal to zero. Below,you can see my wrong solution:

QueryOptions queryOptions = new QueryOptions();
List<String> list = new ArrayList<String>() ;
list.add(“point DESC”) ;
queryOptions.setSortBy(list);
BackendlessDataQuery backendlessDataQuery = new BackendlessDataQuery();
backendlessDataQuery.setQueryOptions(queryOptions);

Backendless.Data.of(BackendlessUser.class).find(backendlessDataQuery, new AsyncCallback&lt;BackendlessCollection&lt;BackendlessUser&gt;>() {
    @Override
    public void handleResponse(BackendlessCollection&lt;BackendlessUser&gt; one) {


        while(one.getCurrentPage().size()>0) {
            Iterator&lt;BackendlessUser&gt; it = one.getCurrentPage().iterator();

            while (it.hasNext()) {

            //something here,not so important 



            }

            one.nextPage(this);// here I want to get next page,
          //but seems like it does not work, cause my loop became infinite







        }

}I think that I have to use nextPage method with AsyncCallback instead of one.nextPage(this) , but if I do so , the method couldn’t keep up with the loop. So, how can I solve my problem?

Hello,

Please see the following article describing how paging works:
https://backendless.com/feature-17-data-paging-or-how-to-efficiently-load-large-data-sets-in-a-mobile-app/

Regards,
Mark