title: Multiple instance of Sharedpreference gives different value for same field
body: <p>I am trying to read the value of a field in sharedpreference using two different instances of sharepreferences. While read by using the first instance is giving the correct result, the second read operation using second instance is returning the default values.Why is it so?Am I missing some important concept here?</p>
  
  <p>Code:</p>
  
  <pre><code>  public void testMethod(){
  
      SharedPreferences pref1=myContext.getSharedPreferences(PreferenceHelper.MY_PREF, myContext.MODE_PRIVATE);
      //Correct value is obtained here...
      String value1=pref1.getString("KEY", "");
  
      SharedPreferences pref2=myContext.getSharedPreferences(PreferenceHelper.MY_PREF, myContext.MODE_PRIVATE);
      //Incorrect value is obtained here...
      String value2=pref2.getString("KEY", "");
  
  }
  </code></pre>
  
  <p>I am doubting this is due to multiple instances of the same preference.Android documentation states:</p>
  
  <pre><code> Only one instance of the SharedPreferences object is returned to any callers for the same name, meaning they will see each other's edits as soon as they are made.
  </code></pre>
  
  <p>Does my case relates to concept in this sentence?</p>