I have found a way to handle this, and I want to share with everyone who needs it.
int limit = 0; while (limit + 100 < numberOfRows) { //Compose the statement String statement = "SELECT * FROM Table ORDER someField LIMIT '"+ limit+"', 100"; //Execute the query Cursor cursor = myDataBase.rawQuery(statement, null); while (cursor.moveToNext()) { Product product = new Product(); product.setAllValuesFromCursor(cursor); productsArrayList.add(product); } cursor.close(); limit += 100; } //Compose the statement String statement = "SELECT * FROM Table ORDER someField LIMIT '"+ (numberOfRows - limit)+"', 100"; //Execute the query Cursor cursor = myDataBase.rawQuery(statement, null); while (cursor.moveToNext()) { Product product = new Product(); product.setAllValuesFromCursor(cursor); productsArrayList.add(product); } cursor.close();
The basic idea is to split your data so that you can use the cursor the way it should be used. It works for 2 seconds for 5k rows if you specified a table.
Thanks Arkde
source share