androidsqlsqliteandroid-cursor

Limit number of rows returned from sqlite


How can I limit the number of rows returned using activity.managedQuery()?

I am pretty sure there isn't a limit function in sqlite. I also do not want to use SQLiteDatabase.query() because I am using URI to get my queries.


Solution

  • Of course there is LIMIT in SQLite. See the SQLite docs. For example:

    SELECT col1, col2 FROM mytable WHERE foo = 'bar' LIMIT 42;