mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-11 13:49:15 -05:00
Issue 395
Fix database connection leak
This commit is contained in:
parent
d34b8119f6
commit
b603d899db
@ -94,8 +94,9 @@ public class Storage implements SharedPreferences
|
||||
long startTime = System.currentTimeMillis();
|
||||
Log.i(Email.LOG_TAG, "Loading preferences from DB into Storage");
|
||||
Cursor cursor = null;
|
||||
SQLiteDatabase mDb = null;
|
||||
try {
|
||||
SQLiteDatabase mDb = openDB();
|
||||
mDb = openDB();
|
||||
|
||||
cursor = mDb.rawQuery("SELECT primkey, value FROM preferences_storage", null);
|
||||
while (cursor.moveToNext()) {
|
||||
@ -112,6 +113,10 @@ public class Storage implements SharedPreferences
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
if (mDb != null)
|
||||
{
|
||||
mDb.close();
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
Log.i(Email.LOG_TAG, "Preferences load took " + (endTime - startTime) + "ms");
|
||||
}
|
||||
@ -193,6 +198,10 @@ public class Storage implements SharedPreferences
|
||||
workingStorage.remove();
|
||||
workingChangedKeys.remove();
|
||||
mDb.endTransaction();
|
||||
if (mDb != null)
|
||||
{
|
||||
mDb.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user