I am trying to query data from sqlite db through CursorLoader. When i go through the documentation in android developer website, i can’t find the limit query.
CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
How can i implement limit in CursorLoader?
Thanks in Advance
The hackish way:
which will result in
ORDER BY ROWID LIMIT 5.ROWIDwould sort by the implicit row ids that SQLite keeps – very close to what happens when you don’t specify a sort oder at all.Not that this is abusing the fact that the order parameter does not check if the supplied value is just a valid order type. Kind of a buffer overflow attack.
A better way would be to define
Uriparameters.Both approaches will only work if the
ContentProvideris compatible with above attempts to limit. There is actually no well-defined way to limit or select certain data from aContentProvider. EachContentProvidercomes with it’s own contract so above will not work with every provider.