Setting Ringtone from android preferences is not working
<p>I am having an reminder application that will allow the user to set the required ringtone for notification from settings option which I implemnted using android preferences.</p>

<p>The ringtone dialog is displayed with the list and the ringtone I select is updated but the selected ringtone is not set to the notification. It always notifies with the default ringtone of the device. </p>

<p>I referred and tried the answers for similar questions but its not working</p>

<p><strong>Preferences.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;PreferenceCategory
            android:title="Settings"&gt;
    &lt;RingtonePreference
            android:name="RingtonePreference"
            android:summary="Select a ringtone"
            android:title="Ringtones"
            android:key="@string/ringtonePref"
            android:defaultValue="content://settings/system/notification_sound"
    /&gt;
&lt;/PreferenceCategory&gt;
&lt;/PreferenceScreen&gt;
</code></pre>

<p><strong>Prefrence.java</strong></p>

<pre><code>public class Preferences extends PreferenceActivity implements OnPreferenceChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
}

@Override
protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    String ringtonePreference;
    SharedPreferences prefs = PreferenceManager
            .getDefaultSharedPreferences(getBaseContext());
    ringtonePreference = prefs.getString("ringtonePref",
            "DEFAULT_RINGTONE_URI");
}
@Override
protected void onResume() {
    super.onResume();
    RingtonePreference pref = (RingtonePreference) findPreference(getString(R.string.ringtonePref));
    pref.setOnPreferenceChangeListener(this);

}

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    // TODO Auto-generated method stub
    updateRingtoneSummary((RingtonePreference) preference, Uri.parse((String) newValue));
    return true;
}

private void updateRingtoneSummary(RingtonePreference preference, Uri ringtoneuri) {
    // TODO Auto-generated method stub
    Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneuri);
    if (ringtone != null)
        preference.setSummary(ringtone.getTitle(this));
    else
        preference.setSummary("Silent");
}

}
</code></pre>

<p><strong>MainActivity.java</strong></p>

<pre><code>    @Override
     public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch(item.getItemId()) {

    case R.id.menu_settings: 
        Intent intent = new Intent(this, Preferences.class); 
        startActivity(intent); 
        return true;
    case R.id.menu_about: 
        Intent i = new Intent(this, About.class); 
        startActivity(i); 
    }

    return super.onMenuItemSelected(featureId, item);
}
</code></pre>

<p><strong>NotificationService.java</strong></p>

<pre><code>NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

    Intent notificationIntent = new Intent(this, ReminderEditActivity.class); 
    notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId); 

    PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); 

    Notification note=new Notification(R.drawable.ic_icon, title, System.currentTimeMillis());
    note.setLatestEventInfo(this, title, "You have a task to be done!", pi);
note.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int)((long)rowId);
    mgr.notify(id, note); 
</code></pre>