Users

Learn how to manage your users with QuickBlox.

Visit our Key Concepts page to get an overall understanding of the most important QuickBlox concepts.

Before you begin

  1. Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
  2. Configure QuickBlox SDK for your app. Check out our Setup page for more details.
  3. Create a user session to be able to use QuickBlox functionality. See our Authentication page to learn how to do it.

Create user

It's recommended to manage user creation at your backend for production. To learn more you can refer to QuickBlox API documentation.

For POCs/MVPs or during development you may want to create users on the fly, you can use signUp() method.

Create a user using the code snippet below. Only login (or email) and password are required. Other fields are optional.

QBUser user = new QBUser();
user.setLogin("johnsmith");
user.setPassword("johnPassword");
        
QBUsers.signUp(user).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {
      
    }

    @Override
    public void onError(QBResponseException exception) {
                
    }
});
val user = QBUser()
user.login = "johnsmith"
user.password = "johnPassword"

QBUsers.signUp(user).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {
        
    }

    override fun onError(exception: QBResponseException? {
        
    }
})

🚧

Security & Privacy

It's recommended to disable permission to create users with application session on production apps once user creation is implemented on your backend.

Email, full name, facebookId and phone number are PII, configure session permissions according to your privacy requirements.

Retrieve users

Get a list of users using the getUsers() method. The code snippet below shows how to get a list of users created between the two given dates, and sorted in descending order.

String field = "created_at";
String typeField = "date";
String sortDesc = "desc";
String sortAsc = "asc";
String paramSort = "order";
String paramFilter = "filter[]";
String searchOperator = "between";
String searchValue = "2021-01-01, 2021-05-06";

ArrayList<GenericQueryRule> rules = new ArrayList<GenericQueryRule>();
rules.add(new GenericQueryRule(paramSort, sortDesc + " " + typeField + " " + field));
rules.add(new GenericQueryRule(paramFilter, typeField + " " + field + " " + searchOperator + " " + searchValue));

QBPagedRequestBuilder requestBuilder = new QBPagedRequestBuilder();
requestBuilder.setRules(rules);
requestBuilder.setPerPage(100);
requestBuilder.setPage(1);

QBUsers.getUsers(requestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> usersList, Bundle bundle) {
      
    }
  
    @Override
    public void onError(QBResponseException exception) {
      
    }
});
val field = "created_at"
val typeField = "date"
val sortDesc = "desc"
val sortAsc = "asc"
val paramSort = "order"
val paramFilter ="filter[]"
val searchOperator = "between"
val searchValue = "2021-01-01, 2021-05-06"
  
val rules = ArrayList<GenericQueryRule>()
rules.add(GenericQueryRule(paramSort, "$sortDesc $typeField $field"))
rules.add(GenericQueryRule(paramFilter,"$typeField $field $searchOperator $searchValue"))

val requestBuilder = QBPagedRequestBuilder()
requestBuilder.rules = rules
requestBuilder.perPage = 100
requestBuilder.page = 1

QBUsers.getUsers(requestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(usersList: ArrayList<QBUser>, bundle: Bundle) {
        
    }

    override fun onError(exception: QBResponseException) {
       
    }
})
ArgumentRequiredDescription
requestBuilderyesAllows to set parameters for the request.

If you want to retrieve only users updated after some specific date time and order search results, you can use operators. This is useful if you cache users somehow and do not want to obtain the whole list of users on every app start. Thus, you can use search and sort operators to list users on the page so that it is easier to see specific users.

If you want to get a paginated list of users from the server, you can set the following fields in the QBPagedRequestBuilder class:

FieldRequiredDescription
perPagenoNumber of records to return in one page.
pagenoNumber of pages with results to be returned.

Search operators

You can use search operators to get more specific search results. The code snippet below shows how to get a list of users filtered by the created_at field and created between the two given dates.

String field = "created_at";
String typeField = "date";
String paramFilter = "filter[]";
String searchOperator = "between";
String searchValue = "2021-01-01, 2021-05-06";

ArrayList<GenericQueryRule> rules = new ArrayList<GenericQueryRule>();
rules.add(new GenericQueryRule(paramFilter, typeField + " " + field + " " + searchOperator + " " + searchValue));

QBPagedRequestBuilder requestBuilder = new QBPagedRequestBuilder();
requestBuilder.setRules(rules);

QBUsers.getUsers(requestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> usersList, Bundle bundle) {
      
    }
  
    @Override
    public void onError(QBResponseException exception) {
      
    }
});
val field = "created_at"
val typeField = "date"
val paramFilter ="filter[]"
val searchOperator = "between"
val searchValue = "2021-01-01, 2021-05-06"
  
val rules = ArrayList<GenericQueryRule>()
rules.add(GenericQueryRule(paramFilter,"$typeField $field $searchOperator $searchValue"))

val requestBuilder = QBPagedRequestBuilder()
requestBuilder.rules = rules

QBUsers.getUsers(requestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(usersList: ArrayList<QBUser>, bundle: Bundle) {
        
    }

    override fun onError(exception: QBResponseException) {
       
    }
})

Here are the search operators you can use to search for the exact data that you need.

Search operatorsApplicable to typesApplicable to fieldsDescription
ltnumber, string, dateid, created_at, updated_at, last_request_at, external_user_id, facebook_idLess Than operator.
gtnumber, string, dateid, created_at, updated_at, last_request_at, external_user_id, facebook_idGreater Than operator.
gtenumber, string, dateid, created_at, updated_at, last_request_at, external_user_id, facebook_idGreater Than or Equal to operator.
lenumber, string, dateid, created_at, updated_at, last_request_at, external_user_id, facebook_idLess or Equal to operator
eqnumber, string, dateid, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_idEqual to operator.
nenumber, string, dateid, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_idNot Equal to operator.
betweennumber, string, dateid, created_at, updated_at, last_request_at, external_user_id, facebook_idContained between values operator.
innumber, string, dateid, full_name, email, login, phone, created_at, updated_at, last_request_at, external_user_id, facebook_idIN array operator.

Sort operators

You can use sort operators to order the search results. The request below will return users by the created_at field sorted in descending order.

String field = "created_at";
String typeField = "date";
String sortDesc = "desc";
String paramSort = "order";

ArrayList<GenericQueryRule> rules = new ArrayList<GenericQueryRule>();
rules.add(new GenericQueryRule(paramSort, sortDesc + " " + typeField + " " + field));

QBPagedRequestBuilder requestBuilder = new QBPagedRequestBuilder();
requestBuilder.setRules(rules);

QBUsers.getUsers(requestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> usersList, Bundle bundle) {
      
    }
  
    @Override
    public void onError(QBResponseException exception) {
      
    }
});
val field = "created_at"
val typeField = "date"
val sortDesc = "desc"
val paramSort = "order"
  
val rules = ArrayList<GenericQueryRule>()
rules.add(GenericQueryRule(paramSort, "$sortDesc $typeField $field"))

val requestBuilder = QBPagedRequestBuilder()
requestBuilder.rules = rules

QBUsers.getUsers(requestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(usersList: ArrayList<QBUser>, bundle: Bundle) {
        
    }

    override fun onError(exception: QBResponseException) {
       
    }
})

Here are the sort operators you can use to order the search results.

Sort operatorApplicable to typesApplicable to fieldsDescription
sortAscAll typesid, full_name, email, login, phone, website, created_at, updated_at,
last_request_at, external_user_id
Search results will be sorted in ascending order by the specified field.
sortDescAll typesid, full_name, email, login, phone, website, created_at, updated_at,
last_request_at, external_user_id
Search results will be sorted in descending order by the specified field.

Retrieve users by ID

To get a list of users by ID for a current account, use the following code snippet.

QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);

ArrayList<Integer> usersIDs = new ArrayList<>();
usersIDs.add(123);
usersIDs.add(234);
usersIDs.add(345);
usersIDs.add(456);

QBUsers.getUsersByIDs(usersIds, pagedRequestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> users, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val pagedRequestBuilder = QBPagedRequestBuilder()
pagedRequestBuilder.page = 1
pagedRequestBuilder.perPage = 50

val usersIDs = ArrayList<Int>()
usersIDs.add(123)
usersIDs.add(234)
usersIDs.add(345)
usersIDs.add(456)

QBUsers.getUsersByIDs(usersIds, pagedRequestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(users: ArrayList<QBUser>?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Or, you can retrieve a single user if needed.

QBUsers.getUser(user.getId()).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
QBUsers.getUser(user.id).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Retrieve user by login

To get a list of users by login for a current account, use the following code snippet.

String userLogin = user.getLogin();
QBUsers.getUserByLogin(userLogin).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val userLogin = user.login
QBUsers.getUserByLogin(userLogin).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException? {

    }
})

Retrieve user by email

To get a list of users by email for a current account, use the following code snippet.

String usersEmail = user.getEmail();
QBUsers.getUserByEmail(usersEmail).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val usersEmail = user.email
QBUsers.getUserByEmail(usersEmail).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Retrieve users by full name

To get a list of users found by the server according to the search query, use the following code snippet.
Search requires min 3 characters.

QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);

QBUsers.getUsersByFullName(searchQuery, pagedRequestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> users, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val pagedRequestBuilder = QBPagedRequestBuilder()
pagedRequestBuilder.page = 1
pagedRequestBuilder.perPage = 50

QBUsers.getUsersByFullName(searchQuery, pagedRequestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(users: ArrayList<QBUser>?, bundle: Bundle?) {
    }

    override fun onError(exception: QBResponseException?) {
    }
})

Retrieve users by phone number

To get a list of users by phone number for a current account, use the following code snippet.

QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);

ArrayList<String> phoneNumbers = new ArrayList<>();
phoneNumbers.add("+380552223344");
phoneNumbers.add("+190229996677");
phoneNumbers.add("78088800444");

QBUsers.getUsersByPhoneNumbers(phoneNumbers, pagedRequestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> users, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val pagedRequestBuilder = QBPagedRequestBuilder()
pagedRequestBuilder.page = 1
pagedRequestBuilder.perPage = 50

val phoneNumbers = ArrayList<String>()
phoneNumbers.add("+380552223344")
phoneNumbers.add("+190229996677")
phoneNumbers.add("78088800444")

QBUsers.getUsersByPhoneNumbers(phoneNumbers, pagedRequestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(users: ArrayList<QBUser>?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Retrieve user by external user ID

If you have your own database with users (we call these databases as "external databases"), you can use External User ID (ExternalID field) in QBUser model to link users from QuickBlox with users from your external database.

QBUsers.getUserByExternalId(user.getExternalId()).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
QBUsers.getUserByExternalId(user.externalId).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Retrieve users by Facebook ID

To get a list of users by Facebook ID for a current account, use the following code snippet.

QBUsers.getUserByFacebookId(user.getFacebookId()).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
QBUsers.getUserByFacebookId(user.facebookId).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Or, if you want to retrieve several users by Facebook IDs, use the following code lines.

ArrayList<String> facebookIds = new ArrayList<>();
facebookIds.add("552223344");
facebookIds.add("90229996677");
facebookIds.add("78088800444");

QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);

QBUsers.getUsersByFacebookId(facebookIds, pagedRequestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> users, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val facebookIds = ArrayList<String>()
facebookIds.add("552223344")
facebookIds.add("90229996677")
facebookIds.add("78088800444")
  
val pagedRequestBuilder = QBPagedRequestBuilder()
pagedRequestBuilder.page = 1
pagedRequestBuilder.perPage = 50

QBUsers.getUsersByFacebookId(facebookIds, pagedRequestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(users: ArrayList<QBUser>?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Retrieve users by tags

To get a list of users by tags for a current account, use the following code snippet.

QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);
 
ArrayList<String> tags = new ArrayList<>();
tags.add("doctor");
tags.add("english");
tags.add("francias");

QBUsers.getUsersByTags(tags, pagedRequestBuilder).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
    @Override
    public void onSuccess(ArrayList<QBUser> users, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
val pagedRequestBuilder = QBPagedRequestBuilder()
pagedRequestBuilder.page = 1
pagedRequestBuilder.perPage = 50
  
val tags = ArrayList<String>()
tags.add("doctor")
tags.add("english")
tags.add("francias")

QBUsers.getUsersByTags(tags, pagedRequestBuilder).performAsync(object : QBEntityCallback<ArrayList<QBUser>> {
    override fun onSuccess(users: ArrayList<QBUser>?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Delete user

A user can delete himself from the platform.

QBUsers.deleteUser(user.getId()).performAsync(new QBEntityCallback<Void>() {
    @Override
    public void onSuccess(Void aVoid, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
QBUsers.deleteUser(user.id).performAsync(object : QBEntityCallback<Void> {
    override fun onSuccess(aVoid: Void?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

Reset user password

It's possible to reset a password via email.

QBUsers.resetPassword(user.getEmail()).performAsync(new QBEntityCallback<Void>() {
    @Override
    public void onSuccess(Void aVoid, Bundle bundle) {

    }

    @Override
    public void onError(QBResponseException exception) {

    }
});
QBUsers.resetPassword(user.email).performAsync(object : QBEntityCallback<Void> {
    override fun onSuccess(aVoid: Void?, bundle: Bundle?) {

    }

    override fun onError(exception: QBResponseException?) {

    }
})

📘

Make sure to enable the email confirmation. This functionality allows application users to confirm their emails. If a user doesn't confirm the email, the emails won't be sent to this user. As a result, a password reset functionality won't work. To enable the email confirmation, proceed as follows:

  1. Go to the Dashboard => YOUR_APP => Users => Settings => User registration confirmation and check the box.
  2. Click the Save button.

🚧

A password reset functionality is available for the Enterprise plan. Contact the sales team for more details.

Update user

Update a user profile by calling the updateUser() method. If you want to change your password, you need to provide 2 parameters: password and newPassword. The updated user entity will be returned.

🚧

You must set null into the user's password field if you do not want to change your password. Otherwise, you will need to add the user's old password to the oldPassword field.

You can update any other field of the user using the updateUser() method. Thus, the snippet below shows how to update a tagList and customData fields.

// set user's tag or tags
StringifyArrayList<String> userTags = new StringifyArrayList<>();
userTags.add("tagOne");
userTags.add("tagTwo");

user.setTags(userTags);

// set user's custom data
JSONObject jsonObject = new JSONObject();
try {
    jsonObject.put("name", "John");
    jsonObject.put("age", 31);
    jsonObject.put("city", "New York");
} catch (JSONException exception) {
    
}

user.setCustomData(jsonObject.toString());

QBUsers.updateUser(user).performAsync(new QBEntityCallback<QBUser>() {
    @Override
    public void onSuccess(QBUser user, Bundle bundle) {
        
    }

    @Override
    public void onError(QBResponseException exception) {
        
    }
});
// set user's tag or tags
val userTags = StringifyArrayList<String>()
userTags.add("tagOne")
userTags.add("tagTwo")

user.tags = userTags

// set user's custom data
val jsonObject = JSONObject()
try {
    jsonObject.put("name", "John")
    jsonObject.put("age", 31)
    jsonObject.put("city", "New York")
} catch (exception: JSONException) {
  
}

user.setCustomData(jsonObject.toString())
        
QBUsers.updateUser(user).performAsync(object : QBEntityCallback<QBUser> {
    override fun onSuccess(user: QBUser?, bundle: Bundle?) {
        
    }

    override fun onError(exception: QBResponseException?) {
        
    }
})
FieldRequiredDescription
tagsnoUser tags. An array of Strings. A tag must include alphanumeric characters only and start with a letter. The tag must be at least 3 and no more than 15 characters long. There are no spaces in the tag format. For example, the "tagOne" format is correct while the "tag one" format is incorrect.

If more that 10 tags are provided, an error is returned: tag list should contain maximum 10 tags.
customDatanoUser custom data. Should be a String. You can convert any data types to String, for example, JSON, XML , etc.

Set user avatar

To set a user avatar, just create and upload a file to the QuickBlox cloud storage and connect it to the user.

To create a file to QuickBlox cloud storage, you should overwrite the file from the device file system to a java.io.File and then write it to the avatar. Then, upload the file to the QuickBlox cloud storage by calling the uploadFileTask() method and passing the avatar to it. Now that the file is uploaded, get the ID of the uploaded file. See this section to learn more about file upload functionality in details.

To connect the file to the user, set the ID of the uploaded file to the fileId field of the user and call the updateUser() method. As a result, the user avatar gets updated.

private void setAvatar() {
    // just as example for User model
    final QBUser user = new QBUser();
    user.setId(123);
 
    String tags = null; 
  
    // create file
    File avatar = new File("path to file");
    // Some logic for write file by OutputStream and InputStream.
  
    // upload file to the server
    boolean fileIsPublic = false;

    QBContent.uploadFileTask(avatar, fileIsPublic, tags, new QBProgressCallback() {
        @Override
        public void onProgressUpdate(int i) {
        // do something to show progress if needed
        }
    }).performAsync(new QBEntityCallback<QBFile>() {
        @Override
        public void onSuccess(QBFile file, Bundle bundle) {
            int uploadedFileId = file.getId();
        
            // add File to User
            user.setFileId(uploadedFileId);
            updateUser(user);
        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
}

private void updateUser(QBUser user) {
    QBUsers.updateUser(user).performAsync(new QBEntityCallback<QBUser>() {
        @Override
        public void onSuccess(QBUser user, Bundle bundle) {

        }

        @Override
        public void onError(QBResponseException exception) {

        }
    });
}
private fun setAvatar() {
    // just as example for User model
    val user = QBUser()
    user.id = 123
    
    val tags:String? = null
      
    // create file
    val avatar = File("path to file")
    // Some logic for write file by OutputStream and InputStream.
   
    // upload file to the server
    val fileIsPublic = false

    QBContent.uploadFileTask(avatar, fileIsPublic, tags) {
        // do something to show progress if needed
    }.performAsync(object : QBEntityCallback<QBFile> {
        override fun onSuccess(file: QBFile?, bundle: Bundle?) {
            val uploadedFileId = file?.id

            // add File to User
            user.fileId = uploadedFileId
            updateUser(user)
        }

        override fun onError(exception: QBResponseException?) {

        }
    })
}

fun updateUser(user : QBUser) {
    QBUsers.updateUser(user).performAsync(object : QBEntityCallback<QBUser> {
        override fun onSuccess(user: QBUser?, bundle: Bundle?) {

        }

        override fun onError(exception: QBResponseException?) {

        }
    })
}

Pass the following arguments to the updateUser() method:

ArgumentRequiredDescription
useryesSpecifies user fields that should be set.

Get user avatar

Now, other users can get your avatar by calling the downloadFileById() method.

int userAvatarId = user.getFileId();
QBContent.downloadFileById(userAvatarId, new QBProgressCallback() {
    @Override
    public void onProgressUpdate(int i) {
        // do something to show progress if needed
    }
}).performAsync(new QBEntityCallback<InputStream>() {
    @Override
    public void onSuccess(InputStream inputStream, Bundle bundle) {
        // receiving input stream
        // just write an InputStream to a file and show it
    }

    @Override
    public void onError(QBResponseException exceptione) {

    }
});
val userAvatarId = user.fileId
QBContent.downloadFileById(userAvatarId) {
    // do something to show progress if needed
}.performAsync(object : QBEntityCallback<InputStream> {
    override fun onSuccess(inputStream: InputStream?, bundle: Bundle?) {
        // receiving input stream
        // just write an InputStream to a file and show it
    }

    override fun onError(exception: QBResponseException?) {

    }
})
ArgumentRequiredDescriotion
userAvatarIDyesFile unique identifier.

What’s Next