I have Activity A which has editTexts and from activity A, a user can go to activity B and fill out more information. Once the user is done on activity B, they press a button and come back to A. I would like to come back to A with the information that the user had filled in to be already there and not have to fill in the information again.
Currently, this is my code for coming back from B to A.
Intent intent = new Intent(NewAddressActivity.this, CreditCardActivity.class);
intent.putExtra("newAddressEntered", true);
intent.putExtra("newAddress", (Serializable) newAddress);
startActivity(intent);
With this code, when the user comes back, the fields on activity A are empty.
*Note - I need to pass data from B to A when going back.
Any tips on how to do this properly would be greatly appreciated.
Thanks
You're actually not "coming back", but starting a new empty intent, thats why the fields are blank again. Instead, you should just call:
Regarding filling related fields from different Activities, I wouldn't recommend that, but if you need to keep it that way, you may have a
singleton
class to store all field values for instance.Also, you could send
B
fields toA
as activity results.-http://developer.android.com/training/basics/intents/result.html
But still, I would recommend keeping all related fields in one Activity.