我试图从数据库中的表中删除所有记录,但我无法删除。有人能帮助我吗?
我正在使用此链接Delete
public void delete()
{
String DELETEPASSCODE_DETAIL = "DELETE * FROM Payment;";
db.execSQL(DELETEPASSCODE_DETAIL);
}
我在这里调用删除功能
private void savepay() {
// TODO Auto-generated method stub
try{
String check;
webService calService=new webService();
dh.open();
Cursor c = dh.pay();
Toast.makeText(getBaseContext(),className+c.getString(1)+c.getString(2)+c.getString(3)+c.getString(4),Toast.LENGTH_LONG).show();
check= calService.paymentReceipt("PaymentReceipt",c.getString(1),c.getString(2),c.getString(3),c.getString(4),c.getString(5),"0");
}
while (c.moveToNext());
dh.delete();//here i called delete function
dh.close();
}
答案 0 :(得分:7)
您的代码应该像
public void delete()
{
String DELETEPASSCODE_DETAIL = "DELETE FROM Payment;";
db.execSQL(DELETEPASSCODE_DETAIL);
}
答案 1 :(得分:2)
答案 2 :(得分:-1)
应该{{1}}而不是DELETE FROM Payment;
请参阅删除查询的结构
见How to write delete query