title: getSharedPrefernces return null only in one activity which works fine on another
body: <p>I'm using following code to save the shared preference.</p>
  
  <pre><code>sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
  SharedPreferences.Editor editor = sharedpreferences.edit();
  editor.clear();
  editor.putString("NIC",nic);
  editor.putString("fName",fName);
  editor.putString("mName",mName);
  editor.putString("lName",lName);
  editor.putString("aNo",aNo);
  editor.putString("lane",aLane);
  editor.putString("city",aCity);
  editor.putString("contactNo",contactNo);
  editor.putString("regDate",regDate);
  editor.putString("cardNo",cardNo);
  editor.putString("balance",balance);
  editor.commit();
  </code></pre>
  
  <p>Using following code to get the shared preference in Profile activity and it's working fine.</p>
  
  <pre><code>private void getPrefs() {
          SharedPreferences userDetails = Profile.this.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
          id = userDetails.getString("NIC", "");
          f_Name = userDetails.getString("fName", "");
          m_Name = userDetails.getString("mName", "");
          l_Name = userDetails.getString("lName", "");
          contact_no = userDetails.getString("contactNo", "");
          a_No = userDetails.getString("aNo", "");
          a_Lane = userDetails.getString("lane", "");
          a_City = userDetails.getString("city", "");
          card_No = userDetails.getString("cardNo", "");
          reg_Date = userDetails.getString("regDate", "");
      }
  </code></pre>
  
  <p>But when I use the same in another activity, it returns null for the id.</p>
  
  <pre><code>private void getPrefs() {
          SharedPreferences userDetails = Travel.this.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
          id = userDetails.getString("NIC", "");
  }
  </code></pre>
  
  <p>mainfest.xml</p>
  
  <pre><code>&lt;activity
              android:name=".Profile"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.example.pavsaranga.scat.PROFILE" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".Travel"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.example.pavsaranga.scat.TRAVEL" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  </code></pre>
  
  <p>can anyone please help me to solve this issue?
  the full code of the Travel Activity</p>
  
  <pre><code>public class Travel extends AppCompatActivity {
  
      TableLayout tl;
      StringBuilder sb;
      String id, result;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.travel);
          tl = (TableLayout)findViewById(R.id.tlTravel);
          getPrefs();
          Thread t1 = new Thread(new Runnable() {
              @Override
              public void run() {
                  getResponse();
              }
          });
          t1.start();
      }
  
      private void getPrefs() {
          SharedPreferences userDetails = getApplicationContext().getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
          id = userDetails.getString("NIC", "");
      }}
  </code></pre>