Just for understanding.
Currently I have an asynctask that works like this:
String doInBackground(Void... params)
//Downloads a JSON and returns it to the onPostExecute().
void onPostExecute(String response)
//Parses the JSON which has an array of stuff and insert into sqlite.
Call changeCursosr and notifyDataSetChanged.
Is this the right way to handle the insertion and refreshing of the listview? Currently I'm experiencing a slight hang whenever it hits the post execute. should I be parsing & inserting the data in the doInBackground instead?
onPreExecute
and onPostExecute
are not suited for any process-intensive things. They are generally reserved for doing things such as starting and stopping a ProgressDialog
.
You should be making network calls as well as database calls inside doInBackground
in addition to processing the data from those resources.