SharedPreferences prefs = getSharedPreferences("Login", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString("mkw", zabaj); editor.apply(); // This line is IMPORTANT. If you miss this one its not gonna work! Toast.makeText(Login.this, "Logged In Successfully", Toast.LENGTH_LONG).show(); finish();
SharedPreferences prefs = getSharedPreferences("Login", MODE_PRIVATE); String string = prefs.getString("mkw", null); ttl.setText(string);
MainActivity
getString()
setText()
commit()
apply()
onResume
override fun onResume() { super.onResume() SharedPreferences prefs = getSharedPreferences("Login", MODE_PRIVATE); String string = prefs.getString("mkw", null); ttl.setText(string); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)