嘿,我是一个新手 Androidian,希望得到一些帮助吗?
android.database.sqlite.SQLiteException:没有这样的列:asd:,编译时:DELETE FROM labels WHERE name=asd
这是我面临的错误,这是代码:
这是 DBhelper 中的方法:
/**
* Delete a label table
* */
public void deleteLabel(String label) {
SQLiteDatabase db = this.getWritableDatabase();
// ContentValues values = new ContentValues();
// values.remove(label);
// Deleting Row
db.delete(TABLE_LABELS, KEY_NAME + "=" + label, null);
db.close(); // Closing database connection
}
这是调用该方法的主要活动代码:
// for spinner onItemListener
// and here is what label is
final String label = parent.getItemAtPosition(position).toString();
Button dialogDeletelButton = (Button) dialog
.findViewById(R.id.deleteButton);
dialogDeletelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// database handler
DatabaseHandler db = new DatabaseHandler(
getApplicationContext());
// inserting new label into database
db.deleteLabel(label);
// Hiding the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(inputLabel.getWindowToken(), 0);
// loading spinner without the deleted data
loadSpinnerData();
}
});