title: Why does my App gets logged out automatically?
body: <p>I have checked the loggedin status in the splash screen.I have saved the logged in status in the SharedPreferences.It works certain time period. I am getting <strong>false</strong> when I print the login status from the SharedHelper and app gets logged out without pressing the logout button. I have implemented as follows: </p>
  
  <pre><code>  handleCheckStatus.postDelayed(new Runnable() {
          @Override
          public void run() {
              Log.w("Handler", "Called");
              if (helper.isConnectingToInternet()) {
                  if (SharedHelper.getKey(context, "loggedIn").equalsIgnoreCase("true")) {
                      showDialog();
                      GetToken();
                      SharedHelper.putKey(context,"loggedIn","true");
                      GoToMainActivity();
                  } else {
                      GoToBeginActivity();
                      handleCheckStatus.removeCallbacksAndMessages(null);
                  }
                  if (alert != null &amp;&amp; alert.isShowing()) {
                      alert.dismiss();
                  }
              } else {
                  showDialog();
                  handleCheckStatus.postDelayed(this, 3000);
              }
          }
      }, 1000);
  
  public void GetToken() {
      try {
          if (!SharedHelper.getKey(context, "device_token").equals("") &amp;&amp; SharedHelper.getKey(context, "device_token") != null) {
              device_token = SharedHelper.getKey(context, "device_token");
              Log.i(TAG, "GCM Registration Token: " + device_token);
          } else {
              device_token = "" + FirebaseInstanceId.getInstance().getToken();
              SharedHelper.putKey(context, "device_token", "" + FirebaseInstanceId.getInstance().getToken());
              Log.i(TAG, "Failed to complete token refresh: " + device_token);
          }
      } catch (Exception e) {
          device_token = "COULD NOT GET FCM TOKEN";
          Log.d(TAG, "Failed to complete token refresh", e);
      }
  
      try {
          device_UDID = android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
          Log.i(TAG, "Device UDID:" + device_UDID);
      } catch (Exception e) {
          device_UDID = "COULD NOT GET UDID";
          e.printStackTrace();
          Log.d(TAG, "Failed to complete device UDID");
      }
  }
  </code></pre>
  
  <p>My SharedHelper class. I have implemented SharedHelper class as follows:</p>
  
  <pre><code>public class SharedHelper {
  
  public static SharedPreferences sharedPreferences;
  public static SharedPreferences.Editor editor;
  
  public static void putKey(Context context, String Key, String Value) {
      sharedPreferences = context.getSharedPreferences("Cache", Context.MODE_PRIVATE);
      editor = sharedPreferences.edit();
      editor.putString(Key, Value);
      editor.commit();
  
  }
  
  public static String getKey(Context contextGetKey, String Key) {
      sharedPreferences = contextGetKey.getSharedPreferences("Cache", Context.MODE_PRIVATE);
      String Value = sharedPreferences.getString(Key, "");
      return Value;
  
  }
  
  public static void clearSharedPreferences(Context context)
  {
      sharedPreferences = context.getSharedPreferences("Cache", Context.MODE_PRIVATE);
      sharedPreferences.edit().clear().commit();
  }
  }
  </code></pre>