Fixed unclosed cursor

This commit is contained in:
Doug Keen 2012-09-25 16:29:28 -07:00
parent f12860d87e
commit 281b7df3d3
1 changed files with 8 additions and 4 deletions

View File

@ -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;