mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-11 21:58:35 -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();
|
long startTime = System.currentTimeMillis();
|
||||||
Log.i(Email.LOG_TAG, "Loading preferences from DB into Storage");
|
Log.i(Email.LOG_TAG, "Loading preferences from DB into Storage");
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
|
SQLiteDatabase mDb = null;
|
||||||
try {
|
try {
|
||||||
SQLiteDatabase mDb = openDB();
|
mDb = openDB();
|
||||||
|
|
||||||
cursor = mDb.rawQuery("SELECT primkey, value FROM preferences_storage", null);
|
cursor = mDb.rawQuery("SELECT primkey, value FROM preferences_storage", null);
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
@ -112,6 +113,10 @@ public class Storage implements SharedPreferences
|
|||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
|
if (mDb != null)
|
||||||
|
{
|
||||||
|
mDb.close();
|
||||||
|
}
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
Log.i(Email.LOG_TAG, "Preferences load took " + (endTime - startTime) + "ms");
|
Log.i(Email.LOG_TAG, "Preferences load took " + (endTime - startTime) + "ms");
|
||||||
}
|
}
|
||||||
@ -193,6 +198,10 @@ public class Storage implements SharedPreferences
|
|||||||
workingStorage.remove();
|
workingStorage.remove();
|
||||||
workingChangedKeys.remove();
|
workingChangedKeys.remove();
|
||||||
mDb.endTransaction();
|
mDb.endTransaction();
|
||||||
|
if (mDb != null)
|
||||||
|
{
|
||||||
|
mDb.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user