Fixed issue #4098: Ringtone#getTitle does not close its cursor.

http://code.google.com/p/android/issues/detail?id=4098
This commit is contained in:
Josh Guilfoyle
2009-10-02 15:39:10 -07:00
parent 5550ef4873
commit 336a0ee90f

View File

@@ -137,11 +137,17 @@ public class Ringtone {
cursor = res.query(uri, MEDIA_COLUMNS, null, null, null);
}
if (cursor != null && cursor.getCount() == 1) {
cursor.moveToFirst();
return cursor.getString(2);
} else {
title = uri.getLastPathSegment();
try {
if (cursor != null && cursor.getCount() == 1) {
cursor.moveToFirst();
return cursor.getString(2);
} else {
title = uri.getLastPathSegment();
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
}