Domanda

I'm getting error in this code.

Cursor cursor = ourDatabase.rawQuery(
    "SELECT * FROM " + DATABASE_TABLE + " WHERE KEY_ID BETWEEN 15 AND 20",
     null);

My LogCat says error near ? ****** BETWEEN ? It says what are you doing. I'm not being able to figure out the mistake. Please help.

È stato utile?

Soluzione

I believe KEY_ID is your variable, like DATABASE_TABLE, not the actual column name. Try:

Cursor cursor = ourDatabase.rawQuery(
    "SELECT * FROM " + DATABASE_TABLE + " WHERE " + KEY_ID + " BETWEEN 15 AND 20",
     null);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top