0
我需要從Sqlite刪除記錄,我的表名是「TABLE_NAME」,並且列名
是「COLUMN1」,我將字符串值從MyTable.java傳遞到mySqliteHelper.java。
我需要刪除這個記錄,我通過了這個值。這是我的示例代碼。
給我暗示或建議。任何幫助表示讚賞。如何使用SQLiteDatabase刪除記錄?
MyTable.java
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Delete Profile");
alert.setMessage("You want to delete this profile?");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
MySQLiteHelper m=new MySQLiteHelper(getBaseContext());
m.deleteBName(other);
deleteMessage();
}
});
MySQLitHelper.java
public void deleteBName(String keyword)
{
try
{
SQLiteDatabase db=this.getWritableDatabase();
db.delete(TABLE_NAME, COLUMN1+"="+keyword, null);
}
catch(Exception e)
{
e.printStackTrace();
}
}
它不工作... – 2012-03-11 06:10:51
什麼問題你越來越......任何錯誤或什麼? – 2012-03-11 06:12:53
沒有任何錯誤,但它不是刪除記錄... – 2012-03-11 06:14:12