Hi I would like to ask how to save the state of an activity and access it when I go back to the very same page. So I have an activity here to allow user to insert the name of a cat, after that, the user will press the bLocation button to a map activity and choosing a location related to the cat name. Once the user finish choosing the location, he will then press a 'back' button in the map activity and going back to the NewCat activity. Now the CatName textfield is empty and what should I do to make the name remain inside the field after there user go to another page then back?
public class NewCat extends AppCompatActivity {
String catName;
EditText catNameInput,catFoodInput,catHabitInput,catAgeInput;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_cat);
final Button bBack=(Button) findViewById(R.id.bBack);
bBack.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent(v.getContext(), MainActivity.class);
startActivityForResult(intent,0);
}
});
final Button bLocation=(Button) findViewById(R.id.bLocation);
bLocation.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent(v.getContext(), mapActivity.class);
startActivityForResult(intent,0);
}
});
final Button bRegister=(Button) findViewById(R.id.bRegister);
bRegister.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
catNameInput = (EditText) findViewById(R.id.etCatName);
catName=(String) catNameInput.getText().toString();
}
});
}