how to go to next page?

Hello
I’m fetching the objects from a Rating table using a where-clause via the following code as described in the documentation -

Backendless.Persistence.of( Rating.class ).find(dataQuery, new AsyncCallback<BackendlessCollection<Rating>>(){
//overrided methods
}

But i’m only able to get the data of current page, I’m not able to navigate to next page.
I saw the feature 17 about data retrieval using paging, but its different than what i’m using.

Please help me.

The BackendlessCollection object you get, has the nextPage() method which fetches the next page from the server.

But the backendlessCollection.nextPage returns an object of BackendlessCollection.
how to get the object of Rating class from it?

BackendlessCollection is a collection (in your case) containing Rating objects.

You can use the getCurrentPage() method to get List<Rating> collection from it.

Yes.
Thank You Mark.
And is there a way i can keep going to next pages till all the objects matching that query are fetched?
Using some loop or any direct way?

You would need to use a loop.

Regards,
Mark

Thank You so much sir.

Hello Sir,

List&lt;Rating&gt; lr = backendlessCollection.nextPage().getCurrentPage();

this code has some error, my app stops when it reaches this line.

Make sure to call it from a new thread. It is a synchronous method. More info is available here:

https://backendless.com/documentation/users/android/users_sync_and_async_api.htm

I tried it sir, but it is still not working. Following log is shown


 BackendlessException{ code: 'Internal client exception', message: 'null' }
                                                                     at com.backendless.Invoker$SyncResponder.errorHandler(Invoker.java:127)
                                                                     at com.backendless.core.responder.AdaptingResponder.errorHandler(AdaptingResponder.java:93)
                                                                     at weborb.client.ioEngine.HttpIOEngine.send(HttpIOEngine.java:213)
                                                                     at weborb.client.ioEngine.HttpIOEngine.invoke(HttpIOEngine.java:145)
                                                                     at weborb.client.WeborbClient.invoke(WeborbClient.java:138)
                                                                     at com.backendless.Invoker.invokeSync(Invoker.java:100)
                                                                     at com.backendless.Persistence.find(Persistence.java:603)
                                                                     at com.backendless.BackendlessCollection.downloadPage(BackendlessCollection.java:101)
                                                                     at com.backendless.BackendlessCollection.getPage(BackendlessCollection.java:81)
                                                                     at com.backendless.BackendlessCollection.nextPage(BackendlessCollection.java:76)
                                                                     at com.hg.user.ryt.TeacherHome.newCallToNextPage(TeacherHome.java:110)
                                                                     at com.hg.user.ryt.TeacherHome$1.handleResponse(TeacherHome.java:85)
                                                                     at com.hg.user.ryt.TeacherHome$1.handleResponse(TeacherHome.java:69)
                                                                     at com.backendless.Persistence$10.handleResponse(Persistence.java:629)
                                                                     at com.backendless.Persistence$10.handleResponse(Persistence.java:621)
                                                                     at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
                                                                     at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
                                                                     at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
                                                                     at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                     at android.os.Looper.loop(Looper.java:136)
                                                                     at android.app.ActivityThread.main(ActivityThread.java:5052)
                                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                                     at java.lang.reflect.Method.invoke(Method.java:515)
                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
                                                                     at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
                                                                     at dalvik.system.NativeStart.main(Native Method)

It does not look like you’re creating a new thread.