Question

I want to use the SQLite clause LIMIT and OFFSET, so that I can fetch my records in pages. But, though I can find the LIMIT clause in the SQLiteQueryBuilder.query() which would effectively limit the number of record in my result. Couldn't find the OFFSET clause anywhere so that I can continue fetching from the point I left. Also, can someone explain to me the exact use of SelectionArgs[] in the query() function, with some example?

Was it helpful?

Solution 2

You can just give the Limit and Offset parameters in the where clause , in this way

tmpCol.query(Tablename, columns, "WHERE Clause LIMIT xx OFFSET yy",
                                selectionArgs[], having, orderBy);

OTHER TIPS

Try this:

db.query(TABLENAME, 
  new String[] { _ID,NAME,CHILDREN },
  NAME+"=? OR "+CHILDREN+" > ? ", 
  new String[] { "John","3"},
  null, 
  null, 
  " 25 OFFSET 100"); //or 100, 25

Please note everything is string, so the where clause replacements must also be strings

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top