title: Save the login state of the user
body: <p>I want that application allows user to login for the first time. And then when user exit the application without logging out, user will be brought back to the same place or layout which comes after the login layout even if user start the application again. But if user logout from the application, user will be brought back to the main login screen.     </p>
  
  <p>From Launcher(splash screen)----->(App)Login page--->(App)Home screen</p>
  
  <p>From Home app----->(App)Home screen</p>
  
  <p>if click logout button</p>
  
  <p>From Launcher(splash screen)----->(App)Login page--->(App)Home screen</p>
  
  <pre><code>My Splash screen code :----
  
      import android.app.Activity;
      import android.content.Intent;
      import android.content.SharedPreferences;
      import android.os.Bundle;
      import android.os.Handler;
      import android.os.Message;
  
      public class splash_start extends Activity{
          Handler handler = new Handler() {
  
             };
  
  
          protected void onCreate(Bundle var1) {
              super.onCreate(var1);
          this.setContentView(R.layout.splash);
  Intend intend =new Intend (splash.this,login.class);
  startactivity(intend)}
  
  
          this.handler.sendEmptyMessageDelayed(0, 2000L);
  
  
          }
  
      }
  
  
      my login.java code :----
  
      public class log_inn extends Activity {
          EditText uname, pass;
          Button login;
          String username, password;
          String loginid;
          ProgressDialog pDialog;
          Intent in;
             SharedPreferences sharedpreferences;
  
          @SuppressLint("NewApi")
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.log_in);
              uname = (EditText) findViewById(R.id.editText1);
              pass = (EditText) findViewById(R.id.editText2);
              login = (Button) findViewById(R.id.button1);
  
              if (android.os.Build.VERSION.SDK_INT &gt; 8) {
                  StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                          .permitAll().build();
                  StrictMode.setThreadPolicy(policy);
              }
  
  
  
              pass.setOnEditorActionListener(new EditText.OnEditorActionListener() {
  
                       @Override
                      public boolean onEditorAction(TextView v, int actionId,
                              KeyEvent event) {
                          // TODO Auto-generated method stub
                           if (actionId == EditorInfo.IME_ACTION_DONE) {
                               login.performClick();
                               return true;
                           }
  
  
                          return false;
                      }
                   });
  
  
  
              login.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
  
                      username = uname.getText().toString().trim();
                      password = pass.getText().toString().trim();
          }
  
      }
  </code></pre>