2

I am trying to delete the all record from the table in database, but I cannot delete. Can anybody help me?

I am using this link Delete

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

am calling the delete function here

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();



            }
Community
  • 1
  • 1
Mercy
  • 1,862
  • 9
  • 39
  • 75

3 Answers3

7

Your code should be like

public void delete() 
{
          String DELETEPASSCODE_DETAIL = "DELETE FROM Payment;";
          db.execSQL(DELETEPASSCODE_DETAIL);
}
nisha.113a5
  • 2,024
  • 16
  • 30
2

Should be:

"DELETE FROM Payment;"

enter image description here

More details: http://www.sqlite.org/lang_delete.html

Jonathan
  • 5,495
  • 4
  • 38
  • 53
-1

It should be DELETE FROM Payment; not DELETE * FROM Payment; See Structure of Delete Query enter image description here see How to write delete query

Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243