public void run() { try { this.mydb = openDatabase(dbname, this.openCbc, this.oldImpl); } catch (Exception e) { Log.e(SQLitePlugin.class.getSimpleName(), "unexpected error, stopping db thread", e); dbrmap.remove(dbname); return; } DBQuery dbq = null; try { dbq = q.take(); while (!dbq.stop) { mydb.executeSqlBatch(dbq.queries, dbq.jsonparams, dbq.queryIDs, dbq.cbc); // NOTE: androidLock[Bug]Workaround is not necessary and IGNORED for sqlite4java (NDK // version). if (this.bugWorkaround && dbq.queries.length == 1 && dbq.queries[0] == "COMMIT") mydb.bugWorkaround(); dbq = q.take(); } } catch (Exception e) { Log.e(SQLitePlugin.class.getSimpleName(), "unexpected error", e); } if (dbq != null && dbq.close) { try { closeDatabaseNow(dbname); dbrmap.remove(dbname); // (should) remove ourself if (!dbq.delete) { dbq.cbc.success(); } else { try { boolean deleteResult = deleteDatabaseNow(dbname); if (deleteResult) { dbq.cbc.success(); } else { dbq.cbc.error("couldn't delete database"); } } catch (Exception e) { Log.e(SQLitePlugin.class.getSimpleName(), "couldn't delete database", e); dbq.cbc.error("couldn't delete database: " + e); } } } catch (Exception e) { Log.e(SQLitePlugin.class.getSimpleName(), "couldn't close database", e); if (dbq.cbc != null) { dbq.cbc.error("couldn't close database: " + e); } } } }