How do I return stored preferences from another activity in Android?
<p>I cant seem to return a string to an activity in my android application from shared preferences.</p>

<p>In my UI class I have this:</p>

<pre><code> SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    format = preferences.getString("BallPref", "number");//not sure what needs to be in value 
</code></pre>

<p>in Preferences.xml I have this:</p>

<pre><code>&lt;ListPreference
            android:name="BallDisplayPreference"
            android:key="BallPref"
            android:summary="Show numbers or notes on balls"
            android:title="Balls"
            android:defaultValue="Fret"
            android:entries="@array/listArray"
            android:entryValues="@array/listValues"  /&gt;
</code></pre>

<p>In the settings class I have this:</p>

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

            SharedPreferences preferences =
 PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = preferences.edit();

            editor.putString("BallPref", "Fret"); // value to store
            editor.commit();
 }
</code></pre>

<p>What I want to do is go into settings, and select my string option. then i want to find out what the user selected when the game starts. this doesn't seem to be working, any ideas on where I am going wrong?</p>
