0

I have a database of about 200 rows and i was wondering how to get rows from ids 50 to 75. Im using the following code to retrieve all the rows from the database.

SQLiteDatabase db = this.getWritableDatabase();
     String selectQuery = "SELECT  * FROM " + TABLE_DETAILS;
     try {
         Cursor cursor = db.rawQuery(selectQuery, null);
         try {
             if (cursor.moveToFirst()) {
                 do {
                    Log.d("Data", cursor.getString(1));
                        Log.d("Data", cursor.getString(3)));
                    Log.d("Data", cursor.getString(4)));
                    Log.d("Data", cursor.getString(5)));
                 } while (cursor.moveToNext());
             }

         } finally {
             try {
                 cursor.close(); 
             } catch (Exception ignore) {

             }
         }
     } finally {
         try {
             db.close();
         } catch (Exception ignore) {

         }
     }

Thanks, Sahil

1 Answer 1

1

you can use where statement like:

 WHERE ids >= 50 AND ids <= 75
Sign up to request clarification or add additional context in comments.

2 Comments

Upvoting, but I think the variable is called ROWID instead of ids. Or maybe it can go by both, I know SQLite does some aliasing there.
thanks @GabeSechan, I have use ids because OPs statement : "how to get rows from ids 50 to 75" , i thought that one column in table is ids.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.