title: Using shared preferences in between activities
body: <p>I am trying to share a shared preference in between two activities of my project, but for some reason I am not able to pass the data.</p>
  
  <p>I have Activity A which reads the shared preference and Activity B that reads as well as edit that shared preference. </p>
  
  <p>Here is the code I am using to write the shared preference in Activity B:</p>
  
  <pre><code>SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.
      MODE_WORLD_WRITEABLE);
  SharedPreferences.Editor editor = sharedPref.edit();
  editor.putString("theme", "black");
  editor.commit();
  </code></pre>
  
  <p>and for reading in Activity A:</p>
  
  <pre><code>SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.
      MODE_WORLD_WRITEABLE);
  String theme=sharedPref.getString("theme","blue");
  </code></pre>
  
  <p>I have tried using the different modes, and it worked in Activity B in PRIVATE mode but it wasn't shared to activity A. For some reasons I think I have two different shared preferences(same name) for the two different activities. How do I use the same shared preference for both the activities ?</p>