Reputation: 1095
I've this select:
final Cursor cursorConversations = getContentResolver().query(
Uri.parse("content://gmail-ls/conversations/" + Uri.encode(mailAddress)),
null, null, null, BaseColumns._ID + " DESC");
ContentQueryMap mQueryMap
= new ContentQueryMap(cursorConversations, BaseColumns._ID, true, null);
With ContentQueyMap I can cache Cursor data and iterate in it also with the Cursor closed (i need it to boost performance).
Now, I want that the select of the Corsor only retrieve the first fifty rows. The solution of looping for 50 times in mQueryMap.getRows().entrySet()
is not right: I don't want that mQueryMap gets all the rows of the Cursor, but only the first fifty.
Any idea? Does exist a where clause to get only first n rows?
Upvotes: 9
Views: 4496
Reputation: 13129
You could do
final Cursor cursorConversations = getContentResolver().query(
Uri.parse("content://gmail-ls/conversations/" + Uri.encode(mailAddress)),
null, null, null, BaseColumns._ID + " DESC " + " LIMIT 5");
"LIMIT x" after your SORT.
Cheers
Upvotes: 18
Reputation: 12823
SELECT * FROM Table_Name LIMIT 5;
That's valid for sqlite. Try adding "LIMIT 5" to your where clause. (I have not tried)
Upvotes: 0