Getting system ringtones

suggest change

This example demonstrates how to fetch the URI’s of system ringtones (RingtoneManager.TYPE_RINGTONE):

private List<Uri> loadLocalRingtonesUris() {
        List<Uri> alarms = new ArrayList<>();
        try {
            RingtoneManager ringtoneMgr = new RingtoneManager(getActivity());

            Cursor alarmsCursor = ringtoneMgr.getCursor();
            int alarmsCount = alarmsCursor.getCount();
            if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) {
                return null;

            while (!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) {
                int currentPosition = alarmsCursor.getPosition();

        } catch (Exception ex) {

        return alarms;

The list depends on the types of requested ringtones. The possibilities are:

In order to get the Ringtones as every Uri must be resolved by the RingtoneManager: osRingtone = RingtoneManager.getRingtone(context, uri);

To play the sound, use the method:

public void setDataSource(Context context, Uri uri)

from MediaPlayer must be initialised and prepared according to the State diagram

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents