From 06236ec7869825aae077398675286d7fe950fccd Mon Sep 17 00:00:00 2001 From: mantas84 Date: Thu, 17 Dec 2015 19:44:01 +0200 Subject: [PATCH] Update SQLiteAssetHelper.java fixes some memory leaks Thanks to CoolMind. contribution source: https://github.com/jgilfelt/android-sqlite-asset-helper/issues/59 https://github.com/jgilfelt/android-sqlite-asset-helper/issues/62 --- .../com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java index ebee1c9..7c256e7 100755 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java @@ -179,6 +179,7 @@ public synchronized SQLiteDatabase getWritableDatabase() { // do force upgrade if (version != 0 && version < mForcedUpgradeVersion) { + db.close(); db = createOrOpenDatabase(true); db.setVersion(mNewVersion); version = db.getVersion(); @@ -288,6 +289,7 @@ public synchronized void close() { mDatabase.close(); mDatabase = null; } + super.close(); } @Override @@ -391,6 +393,7 @@ private SQLiteDatabase createOrOpenDatabase(boolean force) throws SQLiteAssetExc // database already exists if (force) { Log.w(TAG, "forcing database upgrade!"); + db.close(); copyDatabaseFromAssets(); db = returnDatabase(); }