I am passing string to the below code and it gives error :
Error: 08-24 12:57:55.583: E/AndroidRuntime(11640): android.database.sqlite.SQLiteException: near "RAMDEV": syntax error: , while compiling: SELECT chnno FROM EPG WHERE title = BABA RAMDEV KA YOGA
My code is here:
public String SearchChnNo(String title){
String selectQuery = "SELECT " + chn_no + " FROM " + EPG + " WHERE " + pgm_title + " = " + title ; //error
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
String chnno = cursor.getString(1);
return chnno;
}
Expecting
pgm_titleis String you have to puttitlein Single Quotes,So, your final query would be,