Reputation: 174
SQLiteDatabase database = this.getReadableDatabase();
Cursor cursor = database.rawQuery(selectAll + DatabaseSchema.Vehicles.TABLE_NAME + " where " + DatabaseSchema.Vehicles.COLUMN_ID + "=" + id, null);
cursor.moveToFirst();
Here, selectAll = "select * from "
, and COLUMN_ID
is has int datatype. This code returns an empty cursor everytime. Even though data is inserted in table.
When I run query with only "select * from tablename
". It gives me data.
Upvotes: 0
Views: 553
Reputation: 126563
I think that your problem is when you are accesing with cursor.moveToFirst();
try this instead:
SQLiteDatabase database = this.getReadableDatabase();
Cursor cursor = database.rawQuery(selectAll + DatabaseSchema.Vehicles.TABLE_NAME + " where " + DatabaseSchema.Vehicles.COLUMN_ID + "=" + id, null);
if (cursor != null && cursor.moveToFirst()) {
do {
//Do your stuff!
} while (cursor.moveToNext());
}
cursor.close();
Upvotes: 1