title: Setting Ringtones Inside Android App
body: <p>I would like the ability to set the systems ringtones from within my Android application.  I face a slightly interesting issue because I never once in my code refer to the sounds directly, and instead am using a setup that refers to them via ints, so the code I have found online for this doesn't quite apply to me.</p>
  
  <p>I'm not sure whether my code to set the ringtone is correct or not.  It does replace my ringtone, but it never replaces it with the sound I ask it to.  When I was using "Uri.parse" and giving it the path to find the correct file, it would replace the ringtone with nothing.  Now, using "Uri.fromFile", and referring to the sound via a File, it replaces it with a typical telephone sound, which I assume is some sort of default.</p>
  
  <p>I don't get any errors from this, but I do get one warning that seems relevant.  </p>
  
  <pre><code>dataChanged but no participant pkg='com.android.providers.settings' uid=10096
  </code></pre>
  
  <p>It seems to me that I am just not referring to the file properly.  I can get the path to the sound in a String, and of course define them as a File, but I must be missing something somewhere.</p>
  
  <p>Any ideas are appreciated, thank you.</p>
  
  <p>EDIT ::  Well it seems that error only shows up when you "change the ringtone".  So if I were to set the same sound as ringtone again, it would not show up, but if I were to set a different sound it would.  To me this still means that it is seeing everything I am doing, but I am not referencing to the sound properly, so it doesn't know what to put there.</p>
  
  <p>EDIT :: These are the main points of the errors I get when I try to use the same setup that is posted in other examples of settings ringtones.</p>
  
  <p>These are when I first try to set it as a ringtone :</p>
  
  <pre><code>02-01 11:51:20.709: ERROR/MediaPlayerService(1157): Couldn't open fd for content://settings/system/ringtone
  
  02-01 11:51:20.709: ERROR/MediaPlayer(13807): Unable to to create media player
  
  02-01 11:51:20.709: ERROR/RingtoneManager(13807): Failed to open ringtone content://settings/system/ringtone
  
  02-01 11:51:20.709: ERROR/MediaPlayer(13807): Unable to to create media player
  
  02-01 11:51:20.716: WARN/Ringtone(13807): Couldn't set the stream type
  
  02-01 11:51:20.716: WARN/Ringtone(13807): java.io.IOException: setDataSourceFD failed.: status=0x80000000
  </code></pre>
  
  <p>And this is if I go into my volume settings and change the volume of the ringtone :</p>
  
  <pre><code>02-01 11:51:23.568: ERROR/MediaPlayer(13807): Unable to to create media player
  
  02-01 11:51:23.568: ERROR/Ringtone(13807): play() caught 
  
  02-01 11:51:23.568: ERROR/Ringtone(13807): java.io.IOException: setDataSourceFD failed.: status=0x80000000
  </code></pre>