title: how to add "Remember Me" function using checkbox in android studio
body: <p>how to add remember me functionality using check box in android studio?
  i create a login and register activity and i am using json to fetch data,
  here is my login activity code. i am new in android can anyone help me please</p>
  
  <pre><code>    public EditText Username;
          public EditText Password;
          public TextView RegisterLink;
          public Button LoginButton;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
         Username = (EditText) findViewById(R.id.editUsername);
         Password = (EditText) findViewById(R.id.editPassword);
         RegisterLink = (TextView) findViewById(R.id.RegisterLink);
         LoginButton = (Button) findViewById(R.id.buttonSignIn);
  
          RegisterLink.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Intent registerIntent = new Intent(LoginActivity.this, RegisterActivity.class);
                 LoginActivity.this.startActivity(registerIntent);
  
             }
         });
          LoginButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                 final String username = Username.getText().toString();
                 final String password = Password.getText().toString();
  
                  Response.Listener&lt;String&gt; responseListener= new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
  
                          if (username.isEmpty() &amp;&amp; password.isEmpty()){
                              Toast.makeText(getApplicationContext(),
                                      "Username and Password field are empty", Toast.LENGTH_SHORT).show();
                          }else if (password.isEmpty()){
                              Toast.makeText(getApplicationContext(),
                                      "Password field is empty", Toast.LENGTH_SHORT).show();
                          }else if (username.isEmpty()){
                              Toast.makeText(getApplicationContext(),
                                      "username field is empty", Toast.LENGTH_SHORT).show();
                          }else {
                              try {
                                  JSONObject jsonResponse = new JSONObject(response);
                                  boolean success = jsonResponse.getBoolean("success");
  
  
                                  if (success) {
                                      String name = jsonResponse.getString("name");
                                      int age = jsonResponse.getInt("age");
  
                                      Intent intent = new Intent(LoginActivity.this, UserAreaActivity.class);
                                      intent.putExtra("name", name);
                                      intent.putExtra("age", age);
                                      intent.putExtra("username", username);
                                      LoginActivity.this.startActivity(intent);
                                  } else {
                                      AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                                      builder.setMessage("Incorrect Username and Password")
                                              .setNegativeButton("Retry", null)
                                              .create()
                                              .show();
                                  }
                              } catch (JSONException e) {
                                  e.printStackTrace();
                              }
                          }
                      }
  
                  };
  
                  LoginRequest loginRequest = new LoginRequest(username, password, responseListener);
                  RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
                  queue.add(loginRequest);
  
  
              }
          });
  
      }
  }
  </code></pre>
  
  <p>this is my login request activity</p>
  
  <pre><code>    private static final String LOGIN_REQUEST_URL = "http://sam.in/FetchUserData.php";
      private Map&lt;String, String&gt; params;
  
      public LoginRequest(String username, String password, Response.Listener&lt;String&gt; listener) {
          super(Request.Method.POST, LOGIN_REQUEST_URL, listener, null);
          params = new HashMap&lt;&gt;();
          params.put("username", username);
          params.put("password", password);
      }
      @Override
      public Map&lt;String, String&gt; getParams()
      {
          return params;
      }
  
  }
  </code></pre>