質問

I'm trying to set the email in a user obtained from Facebook SDK. If I set the email with any string like this:

user.setEmail("whatever@whwhwh.com"); 
user.saveInBackground();

It works, no problem... it appears in Parse's Data Browser...

If I try to do what I need to do(see code below), then it doesn't work, I've checked the String value and it's ok, it is the needed email....I've tried different things.. no luck.. Please help, thanks.

user.setEmail(user.getProperty("email").toString());
user.saveInBackground();
役に立ちましたか?

解決

Make sure the email being supplied is not used by any other user. This is because an email must be unique.

When calling saveInBackground, it will actually not throw any exception if one does occur. So in your case, if the email is a duplicate, the email won't get saved and no exception is thrown.

To catch an exception with saveInBackground, you can use the SaveCallback.

user.saveInBackground(new SaveCallback() {
  public void done(ParseException e) {
    if (e == null) {
      // No exception
    } else {
      // Exception occured
    }
  }
});

For a list of exceptions you can refer to ParseException.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top