Progress Dialog is paused

78 views Asked by At

Here it is.

Before fetching the data, creating the progress dialog and showing it now fetching data from server using volley library. It working fine. After that I need to send the data to local database as follow:

if (responseStatusCondition) {
   JSONArray jsonArray=response.getJSONArray("response");

   for (int i=0;i<jsonArray.length();i++) {
      JSONObject childJSONObject = jsonArray.getJSONObject(i);

      // Set the flag bit to 1 since data is already at server
      long result = bloodPressureDatabaseFragment.insertIntoBloodPressureDetails(
                          childJSONObject.getInt("systolic"),
                          childJSONObject.getInt("diastolic"),
                          childJSONObject.getLong("timestamp"),1 );
   }
}

Now problem is this, since the fetching part is happening in background is ok. But the insertion data into db part is happening on the Main UI which leads to pause the progress dialog. Is there any way to solve this problem.

I have done insertions part through the AsynckTask. Is there any alternative to do this task. I also read we can this through the use of Async-Await.

It is good if you please comment the reason of downvoting the question.

0

There are 0 answers