RingtoneManager Cursor Not Returning Selected Ringtone Details
<p>I have a <code>DialogFragment</code> that pops up a custom ringtone selector. However, it doesn't get the proper <code>Ringtone</code> after selecting one and clicking OK. Any idea what is wrong below?</p>

<p>The dialog is created by this</p>

<pre><code>    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        rm = new RingtoneManager(getActivity());
        ringtones = rm.getCursor();

        int selected = -1;

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.ringtone);
        builder.setSingleChoiceItems(ringtones,
                selected,
                ringtones.getColumnName(RingtoneManager.TITLE_COLUMN_INDEX),
                mChoiceListener);
        builder.setPositiveButton("OK", this);
        builder.setNegativeButton("Cancel", this);
        return builder.create();

    }

    private DialogInterface.OnClickListener mChoiceListener =
        new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int position) {
                ringtones.moveToPosition(position);
            }

    };
</code></pre>

<p>When the OK button is selected, it is captured by</p>

<pre><code>public void onClick(DialogInterface dialog, int which) {
        Log.d("DayPickerFragment", "onClick");
        switch(which) {
            case Dialog.BUTTON_NEGATIVE:
                dialog.cancel();
                break;

            case Dialog.BUTTON_POSITIVE:
                Uri uri = rm.getRingtoneUri(ringtones.getPosition());
                Ringtone r = RingtoneManager.getRingtone(getActivity(), uri);

                /*** etc ***/

                /*** returned ringtone doesn't match what was selected ***/
                dialog.dismiss();
                break;
        }
    }
</code></pre>

<p>Is this caused by the <code>rm.getRingtoneUri(position)</code> method not corresponding to the <em>ringtones</em> cursor? If so, how do you get a real <code>Uri</code> of the selected item?</p>

<p>Any help is appreciated.</p>
