I am trying to save a username for game in preferences (first time user enters the game, registration screen shows up, and after that whenever user enters the game, username is automatically synchronized).
i tried the following
// in create() method of game class
userPreferences = Gdx.app.getPreferences("userPrefs");
then, in my registration stage
enter.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
user.username = usernameField.getText();
PanBallGame.getGameInstance().userPreferences.putString("username", user.username);
user.requestPath = "/addUser";
new RequestObserver(user);
}
});
but this doesn't save the username in preferences. Can anyone explain how to get this work ? Thank you .