views:

52

answers:

2

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?

A: 

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
A: 

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
I don't think you should put a "WHERE" in the where clause. The API does it foryou.
polyglot