From 281b7df3d363f35f49039f2068292994bdfe4efa Mon Sep 17 00:00:00 2001 From: Doug Keen Date: Tue, 25 Sep 2012 16:29:28 -0700 Subject: [PATCH] Fixed unclosed cursor --- src/com/dougkeen/bart/data/BartContentProvider.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/dougkeen/bart/data/BartContentProvider.java b/src/com/dougkeen/bart/data/BartContentProvider.java index bbae2dc..0e66b3e 100644 --- a/src/com/dougkeen/bart/data/BartContentProvider.java +++ b/src/com/dougkeen/bart/data/BartContentProvider.java @@ -230,10 +230,14 @@ public class BartContentProvider extends ContentProvider { + RoutesColumns.TO_STATION.string + "=?", new String[] { origin, destination }, null, null, null); - if (query.moveToFirst()) { - return update(ContentUris.withAppendedId( - Constants.FAVORITE_CONTENT_URI, query.getLong(0)), - values, where, whereArgs); + try { + if (query.moveToFirst()) { + return update(ContentUris.withAppendedId( + Constants.FAVORITE_CONTENT_URI, query.getLong(0)), + values, where, whereArgs); + } + } finally { + CursorUtils.closeCursorQuietly(query); } } return 0;