android.database.sqlite.SQLiteException:没有这样的列:caolumn值

时间:2016-07-28 05:17:20

标签: android database sqlite

我从数据库表列中获取并匹配值但是它在android中exception no such column name但是android.database.sqlite.SQLiteException: no such column:speech但是语音在列中是值,但是它给出了这个错误

我正在使用此代码

 public List<TextJson> getDetailtospinner(String text_spinner1) {
    SQLiteDatabase db = this.getReadableDatabase();
   List<TextJson> textList = null;
    try{
        textList = new ArrayList<TextJson>();
        String[] columns = new String[]{KEY_ID,KEY_NAME};
        Cursor cursor = db.query(TABLE_TEXTS, columns, KEY_NAME + "=" + text_spinner1, null, null, null, null);
        //Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = " + text_spinner1 , null);
        int rows = cursor.getCount();
        if (cursor != null) {
            Log.e("0_0","0_0   1=>");
            for(int i=0;i<rows;i++) {
                while (cursor.moveToNext()) {
                    TextJson txtlist = new TextJson();
                    Log.e("0_0", ":( ==>");
                    txtlist.setId(cursor.getInt(0));
                    txtlist.setText_status(cursor.getString(1));
                    textList.add(txtlist);
                }
            }
        }
        db.close();
    }catch (Exception e){
        Log.e("error","is==> "  +e);
    }
    return textList;
}

image

1 个答案:

答案 0 :(得分:3)

如果值不是整数,则用'括起条件值。

 Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = '" + text_spinner1 +"'", null);