Reputation: 145
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
Upvotes: 0
Views: 49
Reputation: 11948
you can use where statement like:
WHERE ids >= 50 AND ids <= 75
Upvotes: 1