Bug 1092844 - Part 1: Close execSQL() cursor to fix "Cursor finalized without being closed" warnings. r=mfinkle

--HG--
extra : rebase_source : 352a9bad1eb0404d92dd89354937d84ee416f2a2
This commit is contained in:
Chris Peterson 2014-11-02 01:20:49 -07:00
parent d3913604c5
commit ed4e23dd97

View File

@ -68,13 +68,15 @@ public class SQLiteBridge {
// Executes a simple line of sql.
public void execSQL(String sql)
throws SQLiteBridgeException {
internalQuery(sql, null);
Cursor cursor = internalQuery(sql, null);
cursor.close();
}
// Executes a simple line of sql. Allow you to bind arguments
public void execSQL(String sql, String[] bindArgs)
throws SQLiteBridgeException {
internalQuery(sql, bindArgs);
Cursor cursor = internalQuery(sql, bindArgs);
cursor.close();
}
// Executes a DELETE statement on the database
@ -86,7 +88,7 @@ public class SQLiteBridge {
sb.append(" WHERE " + whereClause);
}
internalQuery(sb.toString(), whereArgs);
execSQL(sb.toString(), whereArgs);
return (int)mQueryResults[RESULT_ROWS_CHANGED];
}
@ -172,7 +174,7 @@ public class SQLiteBridge {
String[] binds = new String[valueBinds.size()];
valueBinds.toArray(binds);
internalQuery(sb.toString(), binds);
execSQL(sb.toString(), binds);
return mQueryResults[RESULT_INSERT_ROW_ID];
}
@ -215,7 +217,7 @@ public class SQLiteBridge {
String[] binds = new String[valueNames.size()];
valueNames.toArray(binds);
internalQuery(sb.toString(), binds);
execSQL(sb.toString(), binds);
return (int)mQueryResults[RESULT_ROWS_CHANGED];
}
@ -350,14 +352,14 @@ public class SQLiteBridge {
// Success! Let's make sure we autocheckpoint at a reasonable interval.
final int pageSizeBytes = bridge.getPageSizeBytes();
final int checkpointPageCount = MAX_WAL_SIZE_BYTES / pageSizeBytes;
bridge.internalQuery("PRAGMA wal_autocheckpoint=" + checkpointPageCount, null).close();
bridge.execSQL("PRAGMA wal_autocheckpoint=" + checkpointPageCount);
} else {
if (!"truncate".equals(journalMode)) {
Log.w(LOGTAG, "Unable to activate WAL journal mode. Using truncate instead.");
bridge.internalQuery("PRAGMA journal_mode=TRUNCATE", null).close();
bridge.execSQL("PRAGMA journal_mode=TRUNCATE");
}
Log.w(LOGTAG, "Not using WAL mode: using synchronous=FULL instead.");
bridge.internalQuery("PRAGMA synchronous=FULL", null).close();
bridge.execSQL("PRAGMA synchronous=FULL");
}
}
} finally {