In your account, do the following:
pref = getSharedPreferences(PREFS_NAME, 0); intent = new Intent(context, LaunchingActivity.class); isChecked = pref.getBoolean("isChecked", false); if(isChecked) startActivity(intent); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if(username.equalsIgnoreCase("") && password.equalsIgnoreCase("")) { username = userEdtTxt.getText().toString(); password = pwdEdtTxt.getText().toString(); } if(checkBox.isChecked()) { editor = pref.edit(); editor.putString("username", username); editor.putString("password", password); editor.putString("isChecked", true); editor.commit(); } startActivity(intent); } });
Then in the starting action do it,
SharedPreferences pref = getSharedPreferences(PREFS_NAME, 0); String username = pref.getString("username", ""); String password = pref.getString("password", "");
source share