Unable to get current user details

String userId = UserTokenStorageFactory.instance().getStorage().get();
Toast.makeText(getApplicationContext(),userId+"",Toast.LENGTH_LONG).show();
Backendless.UserService.findById(userId, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
if (response != null) {
Backendless.UserService.setCurrentUser(response);
Toast.makeText(getApplicationContext(),response.getEmail(),Toast.LENGTH_LONG).show();
}
}
@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(getApplicationContext(),fault.getMessage(),Toast.LENGTH_LONG).show();
}
});

I am unable to fetch logged in user details but the user is already logged in

the userid is retriving wrong object id

This method:

Backendless.UserService.findById

required that the first argument is the value assigned by Backendless. You can see the value in the objectId column in Backendless console

Sir but i am unable to get the details of the logged in user

When i am opening my app again the user is automatically logged in but when I am trying to retrieve the details using the userid…it is giving wrong user details…then I tried to check the value of the userid being retrieved and it is different than what it is specified in the console

the value of userid when i execute this line:

String userId = UserTokenStorageFactory.instance().getStorage().get();

is incorrect. It is not equal to the object id of the user who is logged in. Kindly help.

The following method:

UserTokenStorageFactory.instance().getStorage().get();

Will retrieve user-token. The class name indicates that: UserTokenStorageFactory.

Instead you should use this:

UserIdStorageFactory.instance().getStorage().get()