我从数据库表列中获取并匹配值但是它在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;
}
答案 0 :(得分:3)
如果值不是整数,则用'
括起条件值。
Cursor cursor = db.rawQuery("SELECT * FROM "+TABLE_TEXTS + " WHERE " + KEY_CATE + " = '" + text_spinner1 +"'", null);