title: Shared Preferences reset data when app is force closed or device is restarted
body: <p>I'm developing an application in which I'm storing <code>username</code> and <code>password</code> in <code>SharedPreferences</code>. All things are working fine for me, storing as well as retrieving the values. But I discovered that when I restart the device or the app is force closed the value stored in <code>SharedPreferences</code> is reset. And when I again launch my app I get null values in <code>SharedPreferences</code> key. Here, is what I'm doing for storing the values:</p>
  
  <pre><code>SharedPreferences emailLoginSP;
  
  emailLoginSP = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  emailLoginSP.edit().putString("prefEmailId", email_text).commit();
  emailLoginSP.edit().putString("prefUserId", userIDToken).commit();
  emailLoginSP.edit().putString("prefAccess_token", accessToken).commit();
  
  Intent i = new Intent(LoginWithEmail.this,UserInfoActivity.class);
  i.putExtra("acess_token", accessToken);
  i.putExtra("user_id", userIDToken);
  i.putExtra("emailID", email_text);
  startActivity(i);
  </code></pre>
  
  <p>And, this is how I'm retriving it:</p>
  
  <pre><code>SharedPreferences emailLoginSP = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  
  loginEmail = emailLoginSP.getString("prefEmailId", null);
  loginUserId = emailLoginSP.getString("prefUserId", null);
  loginAccessToken = emailLoginSP.getString("prefAccess_token", null);
  </code></pre>
  
  <p>All things are working fine till now.
  Again I'm stating my problem that I get null values when I force close or restart my device. Can we store it permanently in the app memory? Or, I'm doing something wrong here?</p>
  
  <p>Any help will be appreciated.</p>