Support Topics Documentation Slack YouTube Blog

How to get all backendless app users from android device?

I am want all users who are in registered on backendless app in android application.Please help to achieve this

Hello,
You can access Users table via Backendless.Data API as an ordinary table.
Artur

1 Like

Please give exmple? As i am struggling to achieve this

More about data retrieval:
https://backendless.com/docs/android/data_basic_search.html
https://backendless.com/docs/android/data_general_api.html

Map-driven approach (you will receive a list of Maps (Users)):

DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setPageSize(100);
Backendless.Data.of("Users").find(queryBuilder, new AsyncCallback<List<Map>>() {
           @Override
            public void handleResponse(List<Map> response) {
                System.out.println(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                System.out.println(fault);
            }
        });

OR class-based approach (List of BackendlessUser objects):

DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setPageSize(100);
Backendless.Data.of(BackendlessUser.class).find(queryBuilder, new AsyncCallback<List<BackendlessUser>>() {
            @Override
            public void handleResponse(List<BackendlessUser> response) {
                System.out.println(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                System.out.println(fault);
            }
        });

As you can see DataQueryBuilder is used to set pagesize 100 (number of returned Users). Otherwise default value is 10. In order to get absolutely all objects in Users table - you nextPage(method of query builder) OR read this article to create Codeless service which will retrieve all objects from a table with 1 call from client-side

Anton

Wow thank you so much for above example. You saved my day. I appreciate it.