From 7f10d2be7c989ac785fe9484b340ee560da70be2 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Sat, 6 Jun 2015 13:30:20 -0400 Subject: now closing a lot of cursors that were otherwise staying open --- .../danoeh/antennapod/core/storage/DBReader.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'core/src') diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index cc20b3d37..dc24c5784 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -261,8 +261,8 @@ public final class DBReader { item.getMedia().setItem(item); } } while (cursor.moveToNext()); - cursor.close(); } + cursor.close(); } private static FeedMedia extractFeedMediaFromCursorRow(final Cursor cursor) { @@ -401,6 +401,7 @@ public final class DBReader { queueIds.add(queueCursor.getLong(0)); } while (queueCursor.moveToNext()); } + queueCursor.close(); return queueIds; } @@ -533,6 +534,7 @@ public final class DBReader { i++; } while (cursor.moveToNext()); } + cursor.close(); return itemIds; } @@ -750,6 +752,7 @@ public final class DBReader { } } } + itemCursor.close(); return item; } @@ -775,6 +778,7 @@ public final class DBReader { } else { result = Collections.emptyList(); } + itemCursor.close(); return result; } @@ -813,6 +817,7 @@ public final class DBReader { } } } + itemCursor.close(); return item; } @@ -857,12 +862,16 @@ public final class DBReader { static String getImageAuthentication(final Context context, final String imageUrl, PodDBAdapter adapter) { String credentials = null; Cursor cursor = adapter.getImageAuthenticationCursor(imageUrl); - if (cursor.moveToFirst()) { - String username = cursor.getString(0); - String password = cursor.getString(1); - return username + ":" + password; + try { + if (cursor.moveToFirst()) { + String username = cursor.getString(0); + String password = cursor.getString(1); + return username + ":" + password; + } + return ""; + } finally { + cursor.close(); } - return ""; } /** @@ -902,6 +911,7 @@ public final class DBReader { item.setDescription(description); item.setContentEncoded(contentEncoded); } + extraCursor.close(); adapter.close(); } -- cgit v1.2.3