Browse SDKs · Android
Platform
SDKsAndroid

Get current user profile

Retrieve the cached profile for the authenticated user from local storage using getSelfLocalUserInfo().

Copy

Retrieve a snapshot of the authenticated account's complete profile directly from local storage. This snapshot includes nickname, avatar, custom extension fields, and account-wide preferences. This method reads from local storage without executing network requests.

Code example

OpenIMClient.getInstance().userInfoManager.getSelfLocalUserInfo(
    new OnBase<LocalUser>() {
        @Override
        public void onSuccess(LocalUser user) {
            // Update current user profile using user
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    }
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<LocalUser>YesCallback delivering the asynchronous operation result.

Return value

The successful callback returns the LocalUser entity representing the authenticated user:

FieldDescription
userIDUnique global user ID of the authenticated account.
nicknameCurrent display nickname.
faceURLCurrent avatar URL.
exCustom business extension string.
attachedInfo EnterpriseSupplementary business metadata defined by the application.
globalRecvMsgOptGlobal message reception mode: 0 for normal reception, 1 for rejecting messages, 2 for silent reception without notifications.
addFriendPermission EnterpriseFriend request verification mode; for detailed values, see Set friend request permissions.

If the user updates profile attributes from another client or via server-side APIs, the SDK delivers the changes via OnUserListener.onSelfInfoUpdated. Update local cache records using userID as the primary key. For profile mutation APIs and listener registration, see Update the current user profile.