how to request for the next Page of contents

am fetching data like this
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setPageSize(10); // here am setting the page size (10 items to load at a single fetch )
dataQuery.setWhereClause(whereClause);
Backendless.Data.of(Note.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Note>>() {
@Override
public void handleResponse(BackendlessCollection<Note> notes) {
//here i got the first 10 objects from Note Table
}
@Override
public void handleFault(BackendlessFault fault) {
swipeToReload.setRefreshing(false);
Toast.makeText(getContext(), “” + fault.getMessage(), Toast.LENGTH_LONG).show();
}
});
i wanna know how can i load the data of next page (item 11 - 20) ?

Hi,

I’ve answered on the same your question from this topic.

Is my answer not clear for you?
Please, let us know what you did not understand.
Regards, Ilya

please check my new comment on my other topic @ilya

hey man @ilya thanks for responding but am still confused , we can call the nextPage() function inside the response right ? so what if i want to fetch that next page on a button click ? how am gonna call the nextPage() function from a button’s onClickListener ??

Ok. It looks like I’ve caugth your thought.
In ‘handlerResponse’ method you can set new data collection to static field and than in your handler on button click you should get it from this provider field and call method ‘nextPage’.
I hope it’ll help you. Let us know about you result.
Have fun,
Ilya

hey @ilya thanks for responding , did you mean creating a new Instance of backendlessCollection ? then initialise it with the response 's backendlesscollection?? and then call the nextPage on the instance ??

No, I meant that each time when ‘handlerResponse’ is called and get a new instance of BackboneCollection you should set this instance in some static field. In this case, you will have the current collection in this fields and you will be able to call method ‘nexPage’ of it when and where you would like.

hey man am not getting you can you please show me some codes related to this ? so that i can understand it better

see the below function right now its doing exactly what i want but only one thing that is wrong is that this function is fetching all the data automatically (by moving to next page) now instead of this automation of moving to next page how can i make it manual so that instead of moving automatically it should move to nextPage on button Click (on click == move one page forward )

final boolean[] firstResponse = {true};
final CountDownLatch latch = new CountDownLatch( 1 );
Backendless.Data.of(Note.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Note>>() {
@Override
public void handleResponse(BackendlessCollection<Note> notes) {

    if(firstResponse[0])
    {
        firstResponse[0] =false;
    }
    int size = notes.getCurrentPage().size();
    if( size > 0 )

        notes.nextPage( this );

    else

        latch.countDown();

Please, check out this Pastebin example.

It is not tested either compiled code. Please, use it just to get the idea

hey @ilya thanks a lot its doing exactly what i needed , appreciate your efforts