Java tutorial
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.media.RingtoneManager; import android.support.annotation.NonNull; import java.util.HashMap; import java.util.Map; public class Main { /** * Returns a map of ring tones registered on system. Map key is ring tone name, * value is ring tone uri. * * @param context {@link Context} used to access system data. * @return Map of ring tones. */ public static Map<String, String> getRingtones(@NonNull Context context, int type) { RingtoneManager manager = new RingtoneManager(context); manager.setType(type); Cursor cursor = manager.getCursor(); Map<String, String> map = new HashMap<>(); while (cursor.moveToNext()) { String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX); String notificationUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX); map.put(notificationTitle, notificationUri); } return map; } public static Map<String, String> getRingtones(@NonNull Context context) { return getRingtones(context, RingtoneManager.TYPE_RINGTONE); } }