I have a sqlite db with a lot of data, I'm trying to display a ProgressBar while deleting the db tables. How do I post my method deleteAll in the class AsyncTask?
public void deleteAll(){
AlertDialog.Builder builder2=new AlertDialog.Builder(Bi.this);
builder2.setTitle(getString(R.string.titolo_alert_elimina_tutto));
builder2.setMessage(getString(R.string.testo_alert_elimina_tutto));
builder2.setPositiveButton("OK",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SQLiteDatabase db= mHelper.getWritableDatabase();
db.delete(iTable.TABLE_NAME, null, null);
db.delete(mTable.TABLE_NAME, null, null);
.....
The class AsyncTask
protected class LoadDataTask extends AsyncTask<Context, Integer, String>
{
ProgressDialog myLoadingDialog;
@Override
protected void onPreExecute()
{
myLoadingDialog = new ProgressDialog(Bilancio.this);
myLoadingDialog.setMessage("Loading");
myLoadingDialog.setIndeterminate(false);
myLoadingDialog.setCancelable(false);
myLoadingDialog.show();
super.onPreExecute();
}
@Override
protected String doInBackground(Context... arg0)
{
deleteAll();
return null;
}
@Override
protected void onPostExecute(String result)
{
//showData();
myLoadingDialog.dismiss();
super.onPostExecute(result);
}
}