title: How to avoid SQLiteException locking errors
body: <p>I'm developing an Android application. It has multiple threads reading from and writing to the Android SQLite database. I am receiving the following error:</p>
  
  <blockquote>
    <p>SQLiteException: error code 5: database is locked</p>
  </blockquote>
  
  <p>I understand the SQLite locks the entire db on inserting/updating, but these errors only seem 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 lock the db. Is this possible, or is something else going on?</p>
  
  <p>What's the best way to avoid such locks?</p>