I have created one login page for two users, log in as a user and log in as admin, and save user session using share preferences, want to switch between two activity using share preference. if logined user is admin it starts admin activity and if logined user is user it starts another activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
email = findViewById(R.id.email);
password = findViewById(R.id.password);
checkedStatus = findViewById(R.id.checkbox);
radioGroup2 = findViewById(R.id.workeroruser);
userData = new ArrayList<>();
if(SharedPreferences.getmInstance(this).isLoggedIn()){
if(SharedPreferences.getmInstance(this).getAccountu()=="Admin"){
finish();
startActivity(new Intent(this,AdminViewActivity.class));
return;
}else if (SharedPreferences.getmInstance(this).getAccountu()=="User"){
finish();
startActivity(new Intent(this,UserViewActivity.class));
}
}