User Login (android)

I have a login activity with username and password and a checkbox to set stayLoggedIn to true so the user doesn’t have to login again when the app restart.
In the startActivity I check for userToken to skip the loginActivity if userToken is not null

String userToken = UserTokenStorageFactory.instance().getStorage().get()


if( userToken != null && !userToken.equals( "" ) ) {
// user login is available, skip the login activity/login form
Intent goToMain = new Intent(StartActivity.this, MainActivity.class);
startActivity(goToMain);
} else {
Intent goToLogin = new Intent(StartActivity.this, LoginActivity.class);
startActivity(goToLogin);
}

How can I retrieve currentUser if I skip the loginActivity?

Save it to a local datastore. Sqlite/Paper/Realm etc. does the job well.

I solved getting the objectId of the user loggedIn

String currentUserId = Backendless.UserService.loggedInUser();


Backendless.UserService.findById(currentUserId, new AsyncCallback<BackendlessUser>() {
    @Override
    public void handleResponse(BackendlessUser currentUser) {
        Backendless.UserService.setCurrentUser( currentUser );
    }


    @Override
    public void handleFault(BackendlessFault backendlessFault) {


    }
});