I have seen examples of the Backendless.Persistence.of
results stored in both List<E>
and BackendlessCollection<E>
.
What is it recommended to use BackendlessCollection
instead of List
?
// https://backendless.com/documentation/data/android/data_relations_retrieve.htm
List<Contact> result = Backendless.Persistence.of( Contact.class ).find( dataQuery ).getCurrentPage();
// https://backendless.com/feature-17-data-paging-or-how-to-efficiently-load-large-data-sets-in-a-mobile-app/
BackendlessCollection<Restaurant> restaurants = Backendless.Persistence.of(Restaurant.class).find( dataQuery );
List and BackendlessCollection are not the same. BackendlessCollection contains multiple pages (which you can get as list), so one may say that BackendlessCollection consists of Lists.
upd:
You receive a BackendlessCollection
whenever you call find()
method of the SDK. This main reason this class has to exist is that if you have, say, 1000 rows, it is not efficient to retrieve them all at once, since it would take a lot of time. So BackendlessCollection
initially has only first 10 of them, by default. This number is called a page size.
In order to work with the objects, you need to retrieve them from BackenlessCollection
. You do that with BackendlessCollection.getCurrentPage()
method, which returns a List
with 10 objects, by default. After that you may work with it just like with any other list of objects in Java.
Then you may want to retrieve more than just first 10 objects, so now you call BackendlessCollection.nextPage()
method, which returns another BackendlessCollection
, which now contains the objects from 10 to 20. Again, to work with them you need to retrieve the inner List
with BackendlessCollection.getCurrentPage()
method and use these next 10 objects.