3

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?

Codevalley
  • 4,593
  • 7
  • 42
  • 56

2 Answers2

2

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

Pentium10
  • 204,586
  • 122
  • 423
  • 502
1

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);
Codevalley
  • 4,593
  • 7
  • 42
  • 56