Start a new topic

query in .find method not working properly

hey there!
i want to load the items of a specific user by using .find method with query.
the way i implemented it is given as follows:


String userId = client.getActiveUser().getId();

Query query = client.query().in("_acl", new String[]{"{\"creator\":\""+userId+"\"}"});
todoStore.find(query, new KinveyListCallback<MyTodosDataModel>() {
public void onSuccess(List<MyTodosDataModel> Todo) { ......

the method on success is getting called but it is not loading anything, although this user is having multiple items in collection
what am i doing wrong?

Hello Kinza,

Please try changing the type of the userId variable from "String" To "User". The getActiveUser() call returns a user object and not a string.

Please see an example at the following URL regarding active Users.

NOTE: You need to have a user already logged in to the app for the getActiveUser function to return the User object.

I hope this helps. I will have one of our Android support engineers take a look at this on Monday morning for any additional feedback.


Billy Gee

Hey. Thankyou for replying. Can you please provide me with a query to load all the items of a specific user, when i am having user id (the _acl column value) ?

Hi Kinza,

Let the userId be string only and please try following:

String userId = getKinveyClient().getActiveUser().getId();
System.out.println(" userId : "+userId);
Query query = getKinveyClient().query().in("_acl.creator", new String[]{userId});

Make sure the userId is the same one which is present in '_acl.creator' field. In this case, 'userId' is the id of user which is currently logged in the application. While '_acl.creator' field in entity will contain the id of the user which created that particular entity.

Let us know if this answers your question.


Login or Signup to post a comment