Handle unexpected null cursor and don't forget to close it.

Bug: 5406071
Change-Id: Ia40cf7e5a3e32d6f364e787ee66580c685507571
This commit is contained in:
Amith Yamasani
2011-10-04 15:00:21 -07:00
parent 4838c59f88
commit c86755bfd5

View File

@@ -351,9 +351,12 @@ public class SoundSettings extends SettingsPreferenceFragment implements
try {
Cursor cursor = context.getContentResolver().query(ringtoneUri,
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
summary = cursor.getString(0);
}
cursor.close();
}
} catch (SQLiteException sqle) {
// Unknown title for the ringtone
}