Skip to content

Commit

Permalink
Fixed DB leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomirisola-ett committed Apr 16, 2018
1 parent d5b2b9a commit a831cc0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -288,6 +289,7 @@ public synchronized void close() {
mDatabase.close();
mDatabase = null;
}
super.close();
}

@Override
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -513,4 +516,4 @@ public SQLiteAssetException(String error) {
}
}

}
}

0 comments on commit a831cc0

Please sign in to comment.