Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting ParseUser object

Hi I am using the Parse API's database for users and I was wondering how to get the actual ParseUser object so that I can add fields to it? Would I have to query to get the id first then retrieve the obejct that way? As in

ParseQuery query = new ParseQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback() {
  public void done(ParseObject object, ParseException e) {
    if (e == null) {
      // object will be your game score
    } else {
      // something went wrong
    }
  }
});

Is there an easier way...

like image 411
James Avatar asked Mar 14 '26 06:03

James


1 Answers

Do you mean the currently logged in user?

ParseUser currentUser = ParseUser.getCurrentUser();

Of do you have a relation to a user in another class? If that is the case you can use ParseQuery.include to include that class in the response also.

ParseQuery query = new ParseQuery("GameScore");
query.include("User");
query.getInBackground("xWMyZ4YEGZ", new GetCallback() {
  public void done(ParseObject object, ParseException e) {
    if (e == null) {
      // object will be your game score
      ParseUser user = object.getParseObject("User"); // We have a user object
    } else {
      // something went wrong
    }
  }
});

Be aware for typos made here :)

like image 105
hank Avatar answered Mar 16 '26 21:03

hank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!