0

I am trying to update a field in a ParseUser and I am using an external library to use Parse with Java. Even though I get the ParseUser object and can use functions like getEmail(), getUsername(), the functions like setEmail("[email protected]"), put("friends", list), setUsername("bom") doesn't work.

Any ideas on how to solve this?

void updateParse(int id){
  ParseQuery<ParseUser> query = ParseQuery.getQuery(ParseUser.class);
  query.whereEqualTo("alikeId", 2);
  query.findInBackground(new FindCallback<ParseUser>() {
    public void done(List<ParseUser> results, parse4p.ParseException e) {
      if ( results == null) {
        println("Name not found within the class");
      } else {
        ParseUser temp = results.get(0);
        temp.setEmail("[email protected]");

          }
        }
      }
      );    

}
1
  • Extend ParseUser and add your own methods and fields to it. See this for example: parse.com/questions/… Commented Jan 23, 2015 at 22:53

2 Answers 2

2

The first problem with your code is that even though you set the email, you never actually run temp.saveInBackground(), so the parse database won't be updated.

More importantly, Parse has default security on its User class, that only allows you to edit the values for the currently logged in user. So even if you were to use temp.saveInBackground() in your current context, it wouldn't work as the security for the User class wouldn't allow it.

Sign up to request clarification or add additional context in comments.

3 Comments

ParseUser has to be authenticated first, then it can be updated.
I see. Do you know if there is a way for me to overwrite the User class's security settings?
Sorry, this response is very late, Stackoverflow didnt make me aware of your comment. you can change the permissions for users by double clicking the ACL column value. However I would suggest caution when doing this as the security put around the user class has been done so to keep personal information as secure as possible and changing the permissions may alter this.
0

You can try following sample code to update the parseUser:

ParseUser user = ParseUser.getCurrentUser();
user.increment("logins");
user.saveInBackground(new SaveCallback() {
  public void done(ParseException e) {
    if (e != null) {
      // Saved successfully
    } else {
      // ParseException
    }
  }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.