2

Not a total show stopper for my project, but I'm a little concerned at the performance of SQLITE when I am deleting a specific row from the database.. Sometimes it's taking up to 5 seconds which seems too long and I can imagine users may thing the application has crashed.

My code is very straightforward, the delete call is simply :

boolean result;

result = mDb.delete(ACCIDENTS_MEDIA_TABLE, ACCIDENTS_MEDIA_KEY_ROWID + "=" + rowId, null) > 0;

So nothing odd there, the table is relative small in terms of fields (5) but 2 of those are blob fields so I'm wondering if that can be the reason.

If anyone has experience with this & suggestions how to improve my performance so it's not taking up to 5 seconds to delete a row, that would be appreciated.. Thanks.

Rgds,

3
  • "I can imagine users may thing the application has crashed" -- do your database writes in an AsyncTask or background thread, then. You may wish to watch the "Writing Zippy Android Apps" presentation by Brad Fitzpatrick from the 2010 Google I|O conference. Nov 8, 2010 at 12:21
  • No solution to offer, just wanted to chime in that thus far every time I've gone near Android's database APIs I get similarly inexplicable lag and end up writing a custom storage scheme that doesn't suck. But yeah, suggest you get into the habit of doing all storage access on an AsyncTask by default. Storage is always going to be too slow for the UI thread. Nov 8, 2010 at 12:54
  • Thanks fellas I'll give the AsyncTask approach a go. This is the first time I've had a problem to be honest, most fetches/updates etc have always seemed ok up to now, even on my old trusty G1. Nov 8, 2010 at 13:22

1 Answer 1

0

Using an ASyncTask, or a seperate Runnable/Thread with a handler is, as suggested the best way to approach these type of issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.