Support Topics Documentation Slack YouTube Blog

Getting Data From Table

(Saad Zahoor) #1

I have 10 users and each user has its personal information
So In my UserInformation Table i have some properties

userName , userAge , userNationality , userPassportNumber , userGender , userDateOfBirth and so on

when a user register i get all the information and send the infomation to UserInformation Table and also have a relation with it (Users -> UserInformation)

Problem is when i am getting data from the server

I use the below code

        Backendless.Data.of( UserInformation.class).find(new AsyncCallback<List<UserInformation>>(){
            public void handleResponse( List<UserInformation> foundUserInfo)

                if (foundUserInfo.isEmpty()){

                    Toast.makeText(UserInfo.this, "No Information Is Found", Toast.LENGTH_SHORT).show(); 

                }else {

            public void handleFault( BackendlessFault fault )


i know


this code will return the first object from the list
what i want is to get the information of the logged in user not randomly
Currently i am getting data randomly

Suppose if i login from user wildstone i get the data of unknownUser
i want to fetch the data from the table for the user who is log in

(Mark Piller) #2

Do you need to get just the logged in user? Right now you get a collection of users from the database and use the first one.


(Olha Danylova) #3

In addition to Mark’s answer - you can use this API to get currently logged in user:


(Saad Zahoor) #4

Thank you for your time
My problem solved by using

String ownerId = backendlessUser.getProperty("ownerId").toString();
                String whereClause = "ownerId = '"+ownerId+"' ;
                DataQueryBuilder queryBuilder = DataQueryBuilder.create();
                queryBuilder.setPageSize( 20 ).setOffset( 0 );
                queryBuilder.setWhereClause( whereClause );
Backendless.Data.of( Database.class ).find(queryBuilder1,
                                                new AsyncCallback<List<Database>>()  ...