I have a class which extends Activity this class job is to get some data from a SQLite database on the phone, and init. a ListView with all the data from the database.
This is the method for getting information from the database:
public ArrayList<Case> getFromDatabase() {
ArrayList<Case> c = db1.getAllContacts();
return c;
}
As earlier mentioned this method is inside a class that extends Activity This method is called in the onCreate method. This operation takes about 2 second if the database contains around 15 records. How can I show a ProgressDialog, when user presses the button to start this activity, just to show that something is happening?
Create ProgressDialog as field of the activity by declaring an ProgressDialog variable outside onCreate method:
Create a Handler as field in Activty, by writing following block outside of onCreate method.
now in onCreate method replace your code with following: