From 5b8677f6ac31ce4b52e499fa2d13c976c48d0a91 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 10 Mar 2016 17:48:17 -0800 Subject: Fix dangling read-only db connections --- .../daneren2005/dsub/util/SongDBHandler.java | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java index 859c32dd..f6a1714c 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java +++ b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java @@ -177,9 +177,12 @@ public class SongDBHandler extends SQLiteOpenHelper { dates[0] = cursor.getLong(0); dates[1] = cursor.getLong(1); return dates; - } catch(Exception e) {} - - return null; + } catch(Exception e) { + return null; + } + finally { + db.close(); + } } public synchronized Pair getOnlineSongId(MusicDirectory.Entry entry) { @@ -218,9 +221,12 @@ public class SongDBHandler extends SQLiteOpenHelper { try { cursor.moveToFirst(); return new Pair(cursor.getInt(0), cursor.getString(1)); - } catch(Exception e) {} - - return null; + } catch(Exception e) { + return null; + } + finally { + db.close(); + } } public synchronized Pair getIdFromPath(int serverKey, String path) { SQLiteDatabase db = this.getReadableDatabase(); @@ -231,9 +237,12 @@ public class SongDBHandler extends SQLiteOpenHelper { try { cursor.moveToFirst(); return new Pair(cursor.getInt(0), cursor.getString(1)); - } catch(Exception e) {} - - return null; + } catch(Exception e) { + return null; + } + finally { + db.close(); + } } public static SongDBHandler getHandler(Context context) { -- cgit v1.2.3