How to avoid SQLiteException locking errors

Posted by TheArchedOne on Stack Overflow See other posts from Stack Overflow or by TheArchedOne
Published on 2010-03-07T21:02:48Z Indexed on 2010/05/06 9:08 UTC
Read the original article Hit count: 373

Filed under:
|
|
|

I'm developing an android app. It has multiple threads reading from and writing to the android SQLite db. I am receiving the following error:

SQLiteException: error code 5: database is locked

I understand the SQLite locks the entire db on inserting/updating, but these errors only seems to happen when inserting/updating while I'm running a select query. The select query returns a cursor which is being left open quite a wile (a few seconds some times) while I iterate over it. If the select query is not running, I never get the locks. I'm surprised that the select could be locking the db.... is this possible, or is something else going on?

What's the best way to avoid such locks?

Thanks

TAO

© Stack Overflow or respective owner

Related posts about android

Related posts about java