Mercy Mercy - 27 days ago 7
Android Question

To delete the all record from table in android SQllite Database?

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



}

Answer

Your code should be like

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