TransactionManager.callInTransaction(connectionSource, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
queryForFirst(preparedQuery);
}
});
in a DAO object.
And I see that inside the queryForFirst method
CompiledStatement stmt = preparedStmt.compile(databaseConnection, StatementType.SELECT);
DatabaseResults results = null;
try {
results = stmt.runQuery(objectCache);
if (results.first()) {
logger.debug("query-for-first of '{}' returned at least 1 result", preparedStmt.getStatement());
return preparedStmt.mapRow(results);
} else {
logger.debug("query-for-first of '{}' returned at 0 results", preparedStmt.getStatement());
return null;
}
} finally {
if (results != null) {
results.close();
}
stmt.close();
}
Stmt object ref is AndroidCompiledStatement@41703e60 which inside contains cursor which ref is android.database.sqlite.SQLiteCursor@4174a5c0. However result object ref is AndroidDatabaseResults@4132efa8, which also contains cursor ref is android.database.sqlite.SQLiteCursor@4174a5c0. Then digged into the code I saw that in finally block result and stmt objects were trying to close their related cursor objects. After closing the cursor you do not check if it is already closed. (I see that there is a field called mClosed and appropriate method isClosed()). This leads to warning
W/SQLiteCursor﹕ Close cursor android.database.sqlite.SQLiteCursor@4174a5c0 on null twice or more
Could you tell if it can be fixed or am I wrong here?
Thanks for any help.