title: How to set Ringtone in android?
body: <p>I think this is weird question , but i do not have any clue to solve it . I want to set ringtone from my code , butt i cannot set it. I saw this questions ..
  <a href="https://stackoverflow.com/questions/1986756/setting-ringtone-in-android">Setting Ringtone in Android</a>
  and 
  <a href="https://stackoverflow.com/questions/1986756/setting-ringtone-in-android">Setting Ringtone in Android</a></p>
  
  <p>I use this code .</p>
  
  <pre><code>        ContentValues values = new ContentValues();
          values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
          values.put(MediaStore.MediaColumns.TITLE, "My Song title");
          values.put(MediaStore.MediaColumns.SIZE, 215454);
          values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
          values.put(MediaStore.Audio.Media.ARTIST, "");
          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);
  
          //Insert it into the database
          Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath());
          Uri newUri = activity.getContentResolver().insert(uri, values);
  
          RingtoneManager.setActualDefaultRingtoneUri(myucontext ,RingtoneManager.TYPE_RINGTONE, newUri);                 
  
              Settings.System.putString(activity.getContentResolver(), Settings.System.RINGTONE, newUri.toString());
  </code></pre>
  
  <p>but i am getting this error</p>
  
  <p>W/BackupManagerService(   52): dataChanged but no participant pkg='com.android.p
  roviders.settings' uid=10024</p>
  
  <p>I cannot find why this is happening to my code ? I use log .. </p>
  
  <pre><code>// this is before  i set the ringtone 
  D/testing (  232): New uricontent://media/external/audio/media/46
  i set this uri to  RingtoneManager.setActualDefaultRingtoneUri
  D/testing (  232): Default uricontent://settings/system/ringtone
  After seting the uri when i read the value again i found this setings :((
  D/dalvikvm(  221): GC freed 3861 objects / 221176 bytes in 95ms
  </code></pre>
  
  <p>I give permission to the app ..</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_SETTINGS" &gt;&lt;/uses-permission&gt;
        &lt;uses-permission android:name="android.permission.CHANGE_CONFIGURATION" &gt;&lt;/uses-permission&gt;
        &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" &gt;&lt;/uses-permission&gt;
  </code></pre>
  
  <p>Please help me overcome this error :(( ..</p>