Save gps-location to sqlite continuously
<p>I'm trying to make my own gps-tracker, mainly for bike-rides. I managed to make a usable app, at least for personal use, but I wanted to improve it, and have added ContentProviders, Fragments, CursorAdapters and a Service to receive the onLocationChanges from GPS.</p>

<p>However, I have really no idea how to handle the stream of Locations I'm receiving. My old app just saved them to an ArrayList, so right now my Service is sending a Broadcast to my Activity, that saves them to the ArrayList.</p>

<p>Problem is, that when the ride is over, it takes from 5-15 seconds to save the locations to sqlite (yes, I'm using compiledstatement and transaction), and I would like to avoid that, by saving the locations when received. When I tried to do that, my app became unresponsive (as expected), as I was doing the insert in the UI thread, and I do receive location updates often.</p>

<p>This is of course the most important aspect of the app, so what is the solution?</p>

<ul>
<li><p>I could do the insert in a thread, but since inserting a single record is expensive, I'm not sure it could keep up.</p></li>
<li><p>I could write 25 records (or more) at a time in a transaction, but there will be some logic to keep track of what is saved and what is not.</p></li>
</ul>

<p>Is there other options for a better user-experience ?</p>
