当我想从我的表中删除一行时,toast显示我"错误"该行已被删除
Supprimer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db = dbhelper.getWritableDatabase();
Cursor c = db.rawQuery("DELETE FROM Biblio WHERE nom = \""+user.getText().toString()+"\" AND type= \""+spinner.getSelectedItem().toString()+"\"",null);
if(c.moveToFirst()){
Toast.makeText(getActivity(), "deleted", Toast.LENGTH_LONG).show();
}else{ Toast.makeText(getActivity(),"Erreur",Toast.LENGTH_LONG).show();}
}
});
答案 0 :(得分:1)
rawQuery
返回一个游标,但delete
返回已删除的行,因此我认为rawQuery
语句不常见。我会推荐以下内容:
db.delete ("Biblio", "nom = ? AND type = ?", new String[] {user.getText().toString(), spinner.getSelectedItem().toString()})
您将获得一个int back,即已删除的行数。