Blog Of Sem: android studio get shared preferences

android studio get shared preferences

Yazmak için
if(jsonResult == 1){
    Intent intent = new Intent(MainActivity.this, LoginActivity.class);    intent.putExtra("USERNAME", enteredUsername);    intent.putExtra("MESSAGE", "You have been successfully login");
    SharedPreferences userDetails = getApplicationContext().getSharedPreferences("kullanicibilgisi", MODE_PRIVATE);    SharedPreferences.Editor edit = userDetails.edit();    edit.clear();    edit.putString("kullaniciadi", username.getText().toString());    edit.putString("parola", password.getText().toString());    edit.commit();




okumak için
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);
    SharedPreferences userDetails = getSharedPreferences("kullanicibilgisi", MODE_PRIVATE);    String test1 = userDetails.getString("kullaniciadi", "");    String test2 = userDetails.getString("parola", "");    Toast.makeText(getApplicationContext(), test1, Toast.LENGTH_LONG).show();    Toast.makeText(getApplicationContext(), test2, Toast.LENGTH_LONG).show();