Try the following code snippet, works for me...

ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA,
<<asbolutePathToYourAudioFileHere>>);
values.put(MediaStore.MediaColumns.TITLE, "<<yourRingToneNameHere>>");
values.put(MediaStore.MediaColumns.SIZE, <<yourRingToneFileSize>>);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg");    //
assuming it's an mpeg, of course
values.put(MediaStore.Audio.Media.ARTIST, "<<yourArtistNameHere>>");
// values.put(MediaStore.Audio.Media.DURATION, duration);  // doesn't
appear to be necessary if you don't know
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);

Uri uri = MediaStore.Audio.Media.getContentUriForPath(outPath);
Uri newUri = getContentResolver().insert(uri, values);

RingtoneManager.setActualDefaultRingtoneUri(
                                <<MyActivity>>.this,
                                RingtoneManager.TYPE_RINGTONE,
                                newUri);


To get it from res/raw into the file system use an InputStream to the
resource (using getRawResource()) and an OutputStream to the file
system, then the code snippet above. Hope it helps...
Clive

On Jan 1, 3:24 am, Maxood <[email protected]> wrote:
> I have sounds files in my res/raw folder and i want to select a sound
> to set as aringtoneon the click of a button. Wonder how can i do
> that?
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to