Reputation: 944
I often have more than 50 rows in the tables that I want to return from my Azure Mobile Service to my Android app, and I have created the following function for downloading an entire table:
private void genericPagedLoad(final int count, final Query baseQuery, final MobileServiceSyncTable table) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
int takenCount = 0;
int top = 50;
while (takenCount < count) {
Query query = baseQuery.skip(takenCount).top(top);
try {
table.pull(query).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
takenCount += top;
}
return null;
}
}.execute();
}
which I call with
ListenableFuture<MobileServiceList<Level>> future = mClient.getTable(Level.class).where().includeInlineCount().execute();
Futures.addCallback(future, new FutureCallback<MobileServiceList<Level>>() {
@Override
public void onSuccess(MobileServiceList<Level> levels) {
int count = levels.getTotalCount();
Query q = mClient.getTable(Level.class).where();
genericPagedLoad(count, q, mLevelTable);
}
@Override
public void onFailure(Throwable throwable) {
}
});
However, I would like to download the data in larger chunks than 50, but if I change my variable top
to ex. 100 it will still only download 50 rows and then skip 100 rows. According to this article it should be possible to specify the number of rows with the top()
function (up to 1000 rows), but this apparently does not work as it should. I am using the Azure Android SDK 2.0.1-beta. Is there any way to make the top()
function work as specified?
Upvotes: 0
Views: 1294
Reputation: 231
You can use the top() function like following and it'll return more than 50 rows(1000 at MAX):
mClient.GetTable(Level.class).where().top(150).execute(...
Upvotes: 1