Hi i'm using the following method to set a ringtone

public void setRingTone(Context context){
                        try
                        {
                                Log.d(LOG_TAG,"setRingTone()");
                        String filepath ="/sdcard/schoolbell.mp3";
                        File ringtoneFile = new File(filepath);

                        Log.d(LOG_TAG,"Starting content puts");
                        ContentValues content = new ContentValues();
                        content.put(MediaStore.MediaColumns.DATA,
ringtoneFile.getAbsolutePath());
                        content.put(MediaStore.MediaColumns.TITLE, 
"schoolbell");
                        //content.put(MediaStore.MediaColumns.SIZE, 215454);
                        content.put(MediaStore.MediaColumns.MIME_TYPE, 
"audio/mp3");
                        //content.put(MediaStore.Audio.Media.ARTIST, "Madonna");
                        //content.put(MediaStore.Audio.Media.DURATION, 230);
                        content.put(MediaStore.Audio.Media.IS_RINGTONE, true);
                        //content.put(MediaStore.Audio.Media.IS_NOTIFICATION, 
false);
                        //content.put(MediaStore.Audio.Media.IS_ALARM, false);
                        //content.put(MediaStore.Audio.Media.IS_MUSIC, false);

                        Log.d(LOG_TAG,"Starting database puts");
                        //Insert it into the database
                        Log.i(LOG_TAG, "the absolute path of the file
is :"+ringtoneFile.getAbsolutePath());
                        Uri uri = MediaStore.Audio.Media.getContentUriForPath
(ringtoneFile.getAbsolutePath());
                        Uri newUri = context.getContentResolver().insert(uri, 
content);
                        Uri ringtoneUri = newUri;
                        Log.i(LOG_TAG,"1 the ringtone uri is :"+uri);
                        Log.i(LOG_TAG,"2 the ringtone uri is :"+ringtoneUri);

                        RingtoneManager.setActualDefaultRingtoneUri
(context,RingtoneManager.TYPE_RINGTONE,newUri);
                        }
                        catch (Exception e)
                        {Log.e(LOG_TAG,"Error @3:"+e.getMessage());}
                        }

It works perfectly except i only want it to add the tone if it hasent
been added already, is there any way to get the name of the current
ringtone so i can compare it to the file i want to set as my ring
tone? or another way of doing it?
Any help would be great. Thank you

-- 
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