how to periodically save location updates using async task
<p>Currently I am trying to collect location updates periodically, say for every 10 samples. I am using an arraylist to collect them and clear off the arraylist in the main UI thread once I passed them to the server using async task. In the async task I am loading the arraylist with the one from main UI. The problem is, it is clearing the arraylist in the async task even it is in separate variable. How can I keep the activity in sync. Do I need to sleep the main activity till the async task finishes. I am not sure about the variable. Can some one explain me how to do this.</p>

<pre><code>MainMapActivity(X){
  locationupdate for every 1 min{
  arraylist a;//this collects all location updates 10 samples each time
  call asynctask b;
  clear a;
}
asynctask b{
  arraylist c = getall from  a;
  db= insert(c);//save a into database;
}
</code></pre>

<p>clearing a in main UI clears of variable c. How can I prevent that. The variable c should be only cleared after saving all the data in it.
Thanks</p>
