title: sharedPreferences won't share between activities
body: <p>I'm trying to use SharedPreferences to save settings. But I can't seem to get the data to be shared between any of my activities. The code I'm using does manage to save settings but each activity seems to have it's own version of each variable.</p>
  
  <p>So for example. I have an audio settings activity in which the user can give a value to a variable "musicVolume" which is saved. If I close the game and reload it, then the audio settings activity "remembers" the value. But if I try to load the value into any other activity it doesn't work. But, they can all load and save their own variables of the same name.</p>
  
  <p>These are the methods I'm using to save the variables. There is a copy of each of these methods in each activity.** </p>
  
  <p>As I say, they work, but they can only seem to read and write data for the individual activity in which they are located.</p>
  
  <pre><code>public void SavePreferences(String key, float value) {
          SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.putFloat(key, value);
          editor.commit();
  }
  
  public void LoadPreferences() {
          SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
          musicVolume = sharedPreferences.getFloat("musicVolume", (float)0.123);
          soundEffectsVolume = sharedPreferences
                          .getFloat("soundEffectsVolume", (float)0.123);
  }
  
  public void ClearPreferences() {
          SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.clear();
          editor.commit();
  }
  </code></pre>
  
  <p>** I know there is a better way to do this but I'm a very novice oo programmer. I tried to follow the advice of another thread </p>
  
  <p><a href="https://stackoverflow.com/questions/5734721/android-shared-preferences">Android Shared Preferences</a></p>
  
  <p>but wherever I tried to put the lines       </p>
  
  <pre><code>protected AppPreferences appPrefs;
  appPrefs = new AppPreferences(getApplicationContext());
  </code></pre>
  
  <p>I get an error of one sort or another. But most importantly, reading the other comments on the thread, people are saying that SharedPreferences are automatically shared between activities within the same package anyway, which is how I thought they work.</p>