title: Android Sqlite SQLiteDiskIOException: disk I/O error (code 1290) SQLITE_IOERR_DIR_FSYNC
body: <p>I have quite a lot of customers getting the exception mentioned in the title, but i can't reproduce it on any of my devices.</p>
  
  <p>Bug Reports seem to suggest that the error happens only on Sony devices, but i can't seem to find any reports of Sony doing anything funny with their databases on Android.</p>
  
  <p>The code that triggers this exception is ending a transaction</p>
  
  <pre><code>db.beginTransaction();
  for(some iterator)
      db.execSQL("UPDATE table SET column = " + value + " WHERE other_column = " + something);
  db.setTransactionSuccessful();
  db.endTransaction();
  </code></pre>
  
  <p>The stacktrace from here is:</p>
  
  <pre><code>android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1290)
  at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
  at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:559)
  at android.database.sqlite.SQLiteSession.endTransactionUnchecked(SQLiteSession.java:437)
  at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:401)
  at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:530)
  </code></pre>
  
  <p>The database resides on external storage (but according to customer reports it happens when the external storage is mounted):</p>
  
  <pre><code>SQLiteDatabase db = SQLiteDatabase.openDatabase("/path/to/sqlite", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);
  </code></pre>
  
  <p>Please don't be too harsh about the code, I know that (for instance) there should be a try/catch around the sql statements with endTransaction being in finally, but it would make no difference in this case (and I don't get the resources to clean this legacy mess up at the moment).</p>
  
  <p>I found some old reports about SQLITE_IOERR_DIR_FSYNC on AIX, where fsync() on directories was not supported, but that didn't really help me since i obviously cannot recomplie SQLite with the correct compiler flags on Android...</p>
  
  <p>Any Ideas?</p>