How to get entries on pages in Android

I want to use the SQLite LIMIT and OFFSET clause so that I can get my posts on pages. But, although I can find the LIMIT clause in SQLiteQueryBuilder.query (), which would effectively limit the number of records in my result. Could not find an OFFSET clause anywhere so that I can continue fetching from the remaining point. Also, can someone explain to me the exact use of SelectionArgs [] in the query () function, with some example?

+3
source share
2 answers

You can simply specify the Limit and Offset parameters in the where clause, thus

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

Try the following:

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

Note that all strings are strings, so where clause substitutes must also be strings

+2
source

Source: https://habr.com/ru/post/1751975/


All Articles