I’m reading data from a file -> saving into DB -> Loading my Custom ListView by fetching data from DB.. While Fetching and Saving Data to DB i want to ProgressDialog to appear on my screen i tried these two type
but its not working
Type 1:
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
// importing data from file
// Saving data to the DB
alertDialog.dismiss();
Type 2:
UiDialog uiDialog = new UiDialog(CommoditiesListScreen.this);
CommoditiesListScreen.this.runOnUiThread(uiDialog);
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
alertDialog.getWindow().makeActive();
// importing data from file
// Saving data to the DB
uiDialog.stopDialog();
alertDialog.dismiss();
I tried in both ways it not working, ProgressDialog is not appearing on the screen, Anything else i’ve add or any modification i’ve to do in my cod eplease help me…
Note: When Forgot call dismiss(); in Type 1 Progress appears after ListView loaded and it spins for infinite time..
This is an ideal situation to use
AsyncTaskwhere you can show yourdialogin the methodonPreExecute(), perform your background operations (reading data from a file -> saving into DB ) in the methoddoInBackground()and load and display your list in the methodonPostExecute().