title: Preference Manager not getting value from user preferences
body: <p>I'm making an app where whenever you go to an activity, it plays a sound file. I made a preference in which you can change the sound file it plays. Here's the code for the Preference activity: </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;ListPreference     android:title="Sound"
          android:summary="Pick the sound!"
          android:key="soundChoice"
          android:defaultValue="a"
          android:entries="@array/soundList"
          android:entryValues="@array/soundValues" /&gt;
  
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>and here is the array file stuff:</p>
  
  <pre><code>&lt;string-array name="soundList"&gt;
      &lt;item&gt;Sound 1&lt;/item&gt;
      &lt;item&gt;Sound 2&lt;/item&gt;
      &lt;item&gt;Sound 3&lt;/item&gt;
      &lt;item&gt;Sound 4&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;string-array name="soundValues"&gt;
      &lt;item&gt;a&lt;/item&gt;
      &lt;item&gt;b&lt;/item&gt;
      &lt;item&gt;c&lt;/item&gt;
      &lt;item&gt;d&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p>and here is the onCreate for the Activity that plays the sound file:</p>
  
  <pre><code>    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
      //Have also tried using "this" instead of "getBaseContext(). Same result.
      String choiceSound = SP.getString("soundChoice","a");
  
      // TODO
  
      if(choiceSound == "a"){
  
          mediaPlayer = MediaPlayer.create(this, R.raw.sound1); 
          mediaPlayer.start();
  
      }
      else if(choiceSound == "b") {
  
          mediaPlayer = MediaPlayer.create(this, R.raw.sound2); 
          mediaPlayer.start();
  
      }
      setContentView(R.layout.activity_sounder);
  }
  </code></pre>
  
  <p>My problem is, the SharedPreferences is not getting the value from whatever the user selected.<br>So the mediaplayer is never being created, causing the app to crash whenever I exit the activity because I release the MediaPlayer in the onStop() method.<br>Is my constructor for the SharedPreference/PreferenceManager correct?<br>Any ideas on what I am doing wrong or how I could fix it?</p>