Save user and password Android

this is my logic :

I have a user :

user = new User(newUsername, newPassword);

Random id + password are generated for the user.

uniqueName = UUID.randomUUID().toString();
uniquePassword = UUID.randomUUID().toString();

With a dialog the user can change his password, that happens like follows.

newUsername = userField.getText().toString();
newPassword = passwordField.getText().toString();

I pass it to the model :


Model looks like this :

public User(String username,String password){
    this.username = username;
    this.password = password;

public String getUsername(){
    return username;

public void setUsername(String username){
    this.username = username;

public String getPassword(){
    return password;

public void setPassword(String password){
    this.password = password;

However when i shut the application or change activites the password and user is not saved, any hint for how to save user and password so that if user leaves activity it saves the password/id?

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.