Support Topics Documentation Slack YouTube Blog

Check if exist user

Hello.
How to check the user is exist in the Users backendless table in android?
I wanna send the mobile number to the Users table and check if it exists or not exist.

Hello!
You can create DataQueryBuilder (https://backendless.com/docs/android/data_query.html), where you can specified whereClause (https://backendless.com/docs/android/data_search_with_where_clause.html) and put to Backendless.Data.of(“YOUR_TABLE_NAME”).find() (take a look on example in documentation).

@saeed_noshadi
For Backendless.Data.of(“YOUR_TABLE_NAME”).find() in your case you should put “YOUR_TABLE_NAME” = BackendlessUser.class.
Make sure that you are using Data.of (not Persistence.of).

After registration, all users are saved in the system table Users.

Example of code to get all Users by mobile number (if you added column mobile before)

DataQueryBuilder query = DataQueryBuilder.create(); query.setWhereClause( "mobile = '<your mobile number>'" ); List<BackendlessUser> backendlessUsers = Backendless.Data.of( BackendlessUser.class ).find( query );

And in this case if backendlessUsers.size() == 0 means that there is no Users with such mobile number.

If you still have problems, please, provide any example of code that cause problem.