5

I am trying to read/access an mp3 file in my Raw folder and then set it as default ringtone. But it is not able to find it.

My code is -

                Uri path = Uri.parse("android.resource://com.applenty/LearnToCount/raw/mysoundfile");
            RingtoneManager.setActualDefaultRingtoneUri(
                    getApplicationContext(), RingtoneManager.TYPE_RINGTONE,
                    path);
            Log .i("TESTT", "Ringtone Set to Resource: "+ path.toString());
            RingtoneManager.getRingtone(getApplicationContext(), path)
                    .play();

Waht is wrong in here? I have tried all sort of combination here

nasaa
  • 2,701
  • 8
  • 47
  • 76

1 Answers1

9

This is working for me. (remove LearnToCount)

Uri path = Uri.parse("android.resource://com.applenty/raw/mysoundfile");

And then in your manifest.

<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
rochdev
  • 3,835
  • 2
  • 21
  • 18
  • i am getting the same problem . http://stackoverflow.com/questions/13332991/android-set-ringtone-programatically-not-working can you help me. – Tuhin Bhatt Nov 11 '12 at 16:25