Start a new topic

How to use KinveyReference to create a Friends List?

Hey!
I m trying to implement friends list within my app however i have a problem with getting the users back. This is my code so far and KinveyReferences are being added to User.USER_COLLECTION_NAME.

 

mKinveyClient.user().put(KinveyConstants.FRIENDS, new ArrayList<KinveyReference>())
KinveyReference friend = new KinveyReference(User.USER_COLLECTION_NAME, friendId);
 ((ArrayList<KinveyReference>) mKinveyClient.user().get(KinveyConstants.FRIENDS)).add(friend);
mKinveyClient.user().update(new KinveyUserCallback() {
                        @Override
                        public void onSuccess(User user) {
                            Toast.makeText(AddFriendActivity.this, "update successful", Toast.LENGTH_SHORT).show();
                        }

                        @Override
                        public void onFailure(Throwable throwable) {
                            Toast.makeText(AddFriendActivity.this, "Something went wrong: " + throwable.getMessage(), Toast.LENGTH_SHORT).show();
                        }
                    });

 


 However now i don t know how to get all friends of my active user. I m trying something like that but it does not seem to work.


 

AsyncAppData<User> friends = mKinveyClient.appData(KinveyConstants.FRIENDS, User.class);
        Query query = mKinveyClient.query();

        friends.get(query, new KinveyListCallback<User>() {
            @Override
            public void onSuccess(User[] users) {
                Log.i(TAG, "Got : " + users.length);
            }

            @Override
            public void onFailure(Throwable throwable) {

            }
        });

 


Can someone show what am i doing wrong here?

 

Login or Signup to post a comment