I have a problem with save the value of string or editText in java android. When I redirect from FirstActivity to Second and return after it to First, I need that a String that i fill earlier stay in the place that I wrote it. (Like a cookies in js).
If you want to persist data like cookies, use Shared Preference. Here's a sample //Store text SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString("textKey", editText.getText().toString()); editor.commit(); //Get the data from Shared Preferene sharedpreferences.getString("textKey", null); Code (markup): But if you are just navigating between 2 screens, you should not have to do all that because the screens are not destroyed when you navigate out. Unless you call finish();
I definitely disapprove of save the benefit of string or editText in java android. At the point when I divert from FirstActivity to Second and return after it to First, I want that a String that I fill prior stay in the spot that I composed it. (Like a treats in js).