how to use getSharedPreferences in android
First get the instance of SharedPreferences using SharedPreferences userDetails = context.getSharedPreferences(“userdetails”, MODE_PRIVATE); Now to save the values in the SharedPreferences Editor edit = userDetails.edit(); edit.putString(“username”, username.getText().toString().trim()); edit.putString(“password”, password.getText().toString().trim()); edit.apply(); Above lines will write username and password to preference Now to to retrieve saved values from preference, you can follow below lines of code String userName … Read more