我有这段代码不起作用。谁能告诉我我做错了什么?
String option = names.getText().toString();
Cursor c = db.rawQuery("SELECT * from numbers Where fname=option", null);
更改如下:
Cursor c = db.rawQuery("SELECT * from numbers Where fname='"+option+"' ", null);
尝试这个
String query = "SELECT * from numbers Where fname='"+ option +"'";
database.execSQL(query);
更喜欢使用带有?
占位符的 Prepared Statement。
String option = names.getText().toString();
String query = "SELECT * from numbers Where fname = ?"
Cursor c = db.rawQuery(query, new String[] {option});