Search code examples
codenameone

Username field should come pre-filled with the username of the most recent user


I would like my app to retrieve the most recent signed-in username on the login page. Instead of the username field coming when it's blank, I would like it to come when it is pre-filled with the username of the most recent user.


Solution

  • Do something like this when initializing the text field:

    myTextField.setText(Preferences.get("lastLogin", ""));
    

    Then in the logged-in event processing code:

    Preferences.put("lastLogin", myTextField.getText());