aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-03-10 17:48:17 -0800
committerScott Jackson <daneren2005@gmail.com>2016-03-10 17:48:17 -0800
commit5b8677f6ac31ce4b52e499fa2d13c976c48d0a91 (patch)
tree2bc853ce9b02a864094ac64a9ed3cc2dd436f172 /app/src
parent3ca3c68f27c5717b212514b12de45f5d12e408be (diff)
downloaddsub-5b8677f6ac31ce4b52e499fa2d13c976c48d0a91.tar.gz
dsub-5b8677f6ac31ce4b52e499fa2d13c976c48d0a91.tar.bz2
dsub-5b8677f6ac31ce4b52e499fa2d13c976c48d0a91.zip
Fix dangling read-only db connections
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java27
1 files 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<Integer, String> 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<Integer, String> 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) {