title: How can I change the ringtone in android programmatically?
body: <p>I'm trying to write an app that (among other things) will change the user's ringtone based on their location.</p>
  
  <p>However, I'm having difficulty setting the ringtone of my phone from within my app. I've been able to display a list of the phone's ringtones, and have been using the following code to try and set the ringtone:</p>
  
  <pre><code>RingtoneManager.setActualDefaultRingtoneUri(applicationContext, 
        RingtoneManager.TYPE_RINGTONE,
        MediaStore.Audio.Media.getContentUriForPath(settings.getRingtoneURI()));
  
  Settings.System.putString(c.getContentResolver(), Settings.System.RINGTONE, 
        settings.getRingtoneURI());
  </code></pre>
  
  <p>where settings.getRingtoneURI() returns a string with the URI of the desired ringtone.</p>
  
  <p>When I run this, I receive no errors but the ringtone does not change.</p>
  
  <p>Any advice?</p>