I have the following class for an android application.
public class AccountVO
{
private String id;
private String username;
private String password;
private String email;
private String firstName;
private String lastName;
public AccountVO(String tempID, String tempUserName, String tempPassword, String tempEmail, String tempFirstName, String tempLastName)
{
this.id = tempID;
this.username = tempUserName;
this.password = tempPassword;
this.email = tempEmail;
this.firstName = tempFirstName;
this.lastName = tempLastName;
}
public String getId()
{
return id;
}
public String getUserName()
{
return username;
}
public String getEmail()
{
return email;
}
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
}
I create the following objects in an activity.
AccountVO userAccount = new AccountVO("1", "scott", "password", "scott@mail.com", "Scott", "James");
AccountVO userAccount2 = new AccountVO("2", "john", "password", "jsmith@mail.com", "John", "Smith");
I have another activity where I retrieve the values from the objects which I created above and display them in EditText fields. Suppose I change the data in the fields and click on the “Update” Button, can anyone please tell as to how to update the values in my old AccountVO object? For Example: If I change the email via the edittitext field in “userAccount” AccountVO object (to say scott@abc.com), How to update that value in the same object?
Write a setter for each of the fields you have a getter for, like so:
Then, call the setter in the Update function: