I have an android application using sqlite that starts with a database being created and then filled with a lot of data. I have noticed that occasionally, after the data is entered and the transaction ended, the close method call produces an error 'unable to close due to unfinalised statements' and logCat shows the SQLITE_BUSY error code. I know this error normally occurs where a Cursor is used and not closed but this method doesn't do anything other than insert data. I managed to work around the problem in two ways, firstly by using the isOpen method to loop the close call like so:
finally { writer.endTransaction(); while(writer.isOpen()) { try { writer.close(); } catch(SQLiteException e) { if(e.getMessage().contains("unable to close due to unfinalised statements")) { //do nothing here, loop to try again } else { throw e; } } } and this seems to mean the second time of calling does not error and the program continues, but I have been told this is because the second call to close doesn't actually do anything. Is this true? The second way involves simply adding a thread.sleep after the endTransaction and this seems to stop the error ever occuring. Does this mean the endTransaction returns before the actual commit/rollback is complete?/Is there another reason why this pause might resolve the issue? (Maybe something to do with the way I insert the data?) I have already posted this question on stackoverflow under the name 'Android & SQLite - Occasional error 'unable to close due to unfinalised statements' if anyone wants more explanation or code snippets. Thanks in advance. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users