Use same activity, layout and code. The only difference between edit and add is that in first case you have an Account
object (a class of your own), while in the other you don't have.
So in onCreate
after you've setup the views you can perform a check if in getIntent()
(assuming that for edit the caller activity put the object in intent) you have that Account
object and if so, retain it and fill the activity views with its properties. Also you can change here the header - edit
or add
.
When pressing on a save
button/action menu, if you have the Account
object already you'll perform an update, while for the other case (object retained is null) you'll perform an add.