This is my code to query my android database.
int lastID = -1;
String selectQuery = "SELECT * FROM " + TABLE_MAIN + " WHERE " + KEY_ID + " > " + lastID;
Log.i(LOG, selectQuery);
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);
if (c.moveToFirst())
{
...
}
else
{
return null;
}
For some reason every time this runs (I have debugged it) it always falls into the else of the if statement and I dont know why. This led me to believe that my query is wrong but I cannot see how it is wrong. I know that the table name and column name is correct because it is a globally defined variable. Is anyone able to spot my mistake? Thanks
Test your select like
Some devices (this happen to me in some devices) sqlite integer only works with > 1 without simple quotes, but numbers <= 0 need simple quotes. Why? I don't know.