要从android SQlite数据库中的表中删除所有记录?

时间:2011-12-29 11:12:06

标签: android sqlite

我试图从数据库中的表中删除所有记录,但我无法删除。有人能帮助我吗?

我正在使用此链接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();



            }

3 个答案:

答案 0 :(得分:7)

您的代码应该像

public void delete() 
{
          String DELETEPASSCODE_DETAIL = "DELETE FROM Payment;";
          db.execSQL(DELETEPASSCODE_DETAIL);
}

答案 1 :(得分:2)

应该是:

“从付款中删除”

enter image description here

更多详情:http://www.sqlite.org/lang_delete.html

答案 2 :(得分:-1)

应该{​​{1}}而不是DELETE FROM Payment; 请参阅删除查询的结构 enter image description hereHow to write delete query