unable to edit android shared preferences
<p>Hello there sorry if this is a basic question, I am just starting out in trying to teach myself android programming and can not get this to work. </p>

<p>I have created a set of preferences and can get the user to open and edit them.  I am trying to edit one of these preferences when I receive a text message, however it does not change from code.</p>

<p>I have no idea if this is a problem in my preferences or not.</p>

<p>Thanks in advance.</p>

<pre><code>MY PREFERENCES ACTIVITY

import java.util.prefs.Preferences;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;



public class MyPreferencesActivity  extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.beaconedit);
        PreferenceManager.setDefaultValues(this, R.xml.beaconedit, true); 

         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

        for(int i=0;i&lt;getPreferenceScreen().getPreferenceCount();i++){
            initSummary(getPreferenceScreen().getPreference(i));
            }
    }
    @Override
    protected void onResume(){
        super.onResume();
        getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
        }          

    @Override
    protected void onPause() {
        super.onPause();
        getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
        }
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        updatePrefSummary(findPreference(key));
        }
    private void initSummary(Preference p){
        if (p instanceof PreferenceCategory){
            PreferenceCategory pCat = (PreferenceCategory)p;
            for(int i=0;i&lt;pCat.getPreferenceCount();i++){
                initSummary(pCat.getPreference(i));
                }
            }
        else{
            updatePrefSummary(p);
            }
        }
    private void updatePrefSummary(Preference p){
        if (p instanceof ListPreference) {
            ListPreference listPref = (ListPreference) p;
            p.setSummary(listPref.getEntry());
            }
        if (p instanceof EditTextPreference) {
    EditTextPreference editTextPref = (EditTextPreference) p;
    p.setSummary(editTextPref.getText());

    }

    }

}

MY TEXT MESSAGE RECEIVER (WHEN FINISHED)

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class TextMessageReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent){

        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString("phonenumber", "12345678912");
        editor.commit(); 
    }
}
</code></pre>
