PArya
PArya

Reputation: 1

how to fetch ParseUser object by objectId?

I have objectId and I want to fetch ParseUser object which has same objectId. I have read that we can use get to get ParseUser by id at Parse documentation but syntax is not given there. If anyone know please help me.

I have tried this but it is not working.

ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereEqualTo("objectId", userId);
query.findInBackground(new FindCallback<ParseUser>() {

    @Override
    public void done(List<ParseUser> object, ParseException e) {
        // TODO Auto-generated method stub
        if(e==null)
        for(ParseUser obj: object)
        {
            adress.setText(obj.getString("address"));
            contact.setText(obj.getString("contact"));
        }
        else
        {
            adress.setText("Not found");
        }

    }
}); 

Upvotes: 0

Views: 2236

Answers (1)

kingspeech
kingspeech

Reputation: 1836

You can use the following code to get the user;

ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");
    query.whereEqualTo("objectId",userId);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> objects, ParseException e) {
            if (e == null) {
                //List contain object with specific user id.

            } else {
                // error
            }
        }
    });

Hope this helps Regards.

Upvotes: 6

Related Questions