This example describes the android Setup ringtone implementation code. Share to everyone for your reference. as follows:
public void Setmyringtone (file file) {contentvalues values = new Contentvalues ();
Values.put (MediaStore.MediaColumns.DATA, File.getabsolutepath ());
Values.put (MediaStore.MediaColumns.TITLE, File.getname ());
Values.put (MediaStore.MediaColumns.SIZE, File.length ());
Values.put (MediaStore.MediaColumns.MIME_TYPE, "Audio/mp3");
Values.put (MediaStore.Audio.Media.ARTIST, "Madonna");
Values.put (MediaStore.Audio.Media.DURATION, 230);
Values.put (MediaStore.Audio.Media.IS_RINGTONE, true);
Values.put (MediaStore.Audio.Media.IS_NOTIFICATION, false);
Values.put (MediaStore.Audio.Media.IS_ALARM, false);
Values.put (MediaStore.Audio.Media.IS_MUSIC, false);
Uri uri = MediaStore.Audio.Media.getContentUriForPath (File.getabsolutepath ());
Uri Newuri = This.getcontentresolver (). Insert (URI, values);
Ringtonemanager.setactualdefaultringtoneuri (This, Ringtonemanager.type_ringtone, Newuri); }
The key statement for setting ringtones here is:
Ringtonemanager.setactualdefaultringtoneuri (This, Ringtonemanager.type_ringtone, Newuri);
I hope this article will help you with your Android program.