I have SQLiteOpenHelper Database in my android app. On PC where i have derby database, i use this sql order.
SQLiteDatabase db = this.getWritableDatabase();
String sqlOrder = "SELECT * FROM " + TABLE_NAME + " ORDER BY ID ASC OFFSET 40 ROWS";
Cursor res = db.rawQuery(sqlOrder, null);
But on android doesnt work.
android.database.sqlite.SQLiteException: near "OFFSET": syntax error (code 1): , while compiling: SELECT * FROM Messages_table ORDER BY ID ASC OFFSET 40 ROWS
Any substitute?
You have syntax for SQL Server and not for SQL used in sqlite.
Instead of OFFSET 40 ROWS
, use something like LIMIT x OFFSET y
where x
is the number of rows you want to retrieve at a time and y
is your offset you want to start retrieving results from.