Merge "Handle unexpected null cursor and don't forget to close it."
This commit is contained in:
committed by
Android (Google) Code Review
commit
040ad494c5
@@ -351,9 +351,12 @@ public class SoundSettings extends SettingsPreferenceFragment implements
|
|||||||
try {
|
try {
|
||||||
Cursor cursor = context.getContentResolver().query(ringtoneUri,
|
Cursor cursor = context.getContentResolver().query(ringtoneUri,
|
||||||
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
|
new String[] { MediaStore.Audio.Media.TITLE }, null, null, null);
|
||||||
|
if (cursor != null) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
summary = cursor.getString(0);
|
summary = cursor.getString(0);
|
||||||
}
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
} catch (SQLiteException sqle) {
|
} catch (SQLiteException sqle) {
|
||||||
// Unknown title for the ringtone
|
// Unknown title for the ringtone
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user