I have user with score 5. after i want update with user with score 6. Can you help me.
ParseUser user = ParseUser.getCurrentUser();
if (user == null){
return;
}
if (userName.equals(user.getUsername())) {
user.put(PlayerModel.PARSE_FIELD_SCORE_PLAYER,
6);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(final ParseException e) {
if (e != null) {
Log.e(">>>>>PlayerProvider",e.getMessage());
}
}
});
}
After i change same code bellow, but no success. Can you help me.
user.saveInBackground(new SaveCallback() {
public void done(com.parse.ParseException e) {
// TODO Auto-generated method stub
if (e != null) {
Log.e(">>>>>PlayerProvider",e.getMessage());
} else {
}
}
});
Log error
09-30 10:23:13.512 19848-19848/com.demo.b E/>>>>>PlayerProvider﹕ username vbox86pvbox86p16Samsung Galaxy S3 - 4.1.1 - API 16 - 720x1280000000000000000310260000000000 already taken
You can use incremen
.
Docs here: https://parse.com/docs/android/guide#objects-counters
Ex:
ParseUser user = ParseUser.getCurrentUser();
user.incremen(PlayerModel.PARSE_FIELD_SCORE_PLAYER);
user.saveInBackground();
Edited:
ParseUser user = ParseUser.getCurrentUser();
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.getInBackground(user.getObjectId(), new GetCallback<ParseUser>() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (e == null) {
parseUser.put(PlayerModel.PARSE_FIELD_SCORE_PLAYER, 9999);
parseUser.saveInBackground();
}
}
});