Getting all items at once not possible

Hey there,
we are using Version 3.0.11 of your Android SDK and have the following problem: We cannot fetch all items of one class by using the find method.
E.g. this code:

BackendlessDataQuery query = new BackendlessDataQuery();
QueryOptions options = new QueryOptions();
options.setSortBy(Arrays.asList("street"));
query.setQueryOptions(options);
BackendlessCollection<MyClass> result = Backendless.Persistence.of( MyClass.class ).find( query );

Results in this error: BackendlessException{ code: ‘Internal client exception’, message: ‘null’ }
However, using this code it works:

MyClass.findAsync(query, new AsyncCallback<BackendlessCollection<MyClass>>() {
@Override
public void handleResponse(BackendlessCollection< MyClass > response) {
 int size = response.getCurrentPage().size();
 if (size > 0) {
 elements.addAll(response.getData());
 response.nextPage(this);
 } else {
 EventBus.getDefault().post(new BackendlessCollectionEvent(response, elements));
 }
}
@Override
public void handleFault(BackendlessFault fault) {
 EventBus.getDefault().post(new BackendlessFaultEvent(fault));
}
});

Of course, since the paging needs multiple requests, it is slower than using a simple find. I am using this in a similar way on iOS and there it works just fine. Any hints?
Thanks a lot!
Best regards,
Martin

Hi Martin,
Do you use it on Android? If so, Android restricts long-running operations in main thread. That is why AsyncCallback is used.
Artur.

Hi Artur,

this is a good point, yes I am using Android. Okay then instead use this example:

Backendless.Persistence.of(MyClass.class).find(query, new AsyncCallback<BackendlessCollection<MyClass>>() {
    @Override
    public void handleResponse(BackendlessCollection< MyClass > response) {

        ArrayList<MyClass> arrayList = new ArrayList<>();
        arrayList.addAll(response.getData());

        EventBus.getDefault().post(new BackendlessCollectionEvent(response, arrayList));

    }

    @Override
    public void handleFault(BackendlessFault fault) {
        EventBus.getDefault().post(new BackendlessFaultEvent(fault));
    }
});

In this case paging is automatically enabled. Thus, this is not simply an async find. I still have to iterate over the pages. Can I somehow turn paging off here or is it mandatory when using Android in contrast to the iOS implementation?

Thank you!
Best,
Martin

The paging cannot be turned off. We’re planning to increase the max page size value, but for now it’s 100.