dimanche 6 mars 2016

Android _id in SCA.

I have this error on populating my listview from database.

Caused by: java.lang.IllegalArgumentException: column '' does not exist

Heres my code.

public Cursor getData(String hlth_cond) {
    SQLiteDatabase db = this.getReadableDatabase();
    String StringQuery = "SELECT _ID AS _id, RECIPE_NAME FROM "+ TBL_NAME;
    if(hlth_cond == "Highblood"){
        StringQuery = "SELECT _ID AS '_id', RECIPE_NAME FROM "+ TBL_NAME;
    }
    else if (hlth_cond == "Arthritis"){
        StringQuery = "SELECT _ID AS _id , RECIPE_NAME FROM " + TBL_NAME_Arth;
    }
    else if (hlth_cond == "Diabetic"){
        StringQuery = "SELECT _ID AS _id, RECIPE_NAME FROM " + TBL_NAME_Dia;
    }
    Cursor res;
    return res = db.rawQuery(StringQuery,null);

}

Aucun commentaire:

Enregistrer un commentaire