I'm storing 10 different booleans to the cloud with Parse.com , the issue I'm having is that if a user changes one booleans value and saves, all the rest that wasn't set before saving are undefined with the new objectID. I simply want to update one of the values of the Object, not rewrite and create a whole new row with new objectID etc.
The workflow I had in mind was: 1. User changes some settings giving some new values to the booleans in the "Settings" ParseObject:
prefs.put("audio", true);
prefs.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
preferences.putBoolean("audioLocal", true);
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
preferences.flush();
setScreen(new MainScreen(main));
}
});
} else {
utils.toast_error("Failed, something went wrong.");
}
}
});
It saves in background as shown above.
In my main class's create method I fetch all the data and apply it to local preferences.
prefs = new ParseObject("Preferences");
if(ParseUser.getCurrentUser() != null){
prefs.setACL(new ParseACL(ParseUser.getCurrentUser()));
}
query.getInBackground(prefs.getObjectId(), new GetCallback<ParseObject>() {
@Override
public void done(ParseObject parseObject, ParseException e) {
if(e == null){
if(parseObject.getBoolean("audio")){
preferences.putBoolean("audioLocal", true);
}
preferences.flush();
}else{
utils.toast_error("Check your internet connection");
}
}
});
How I noticed this issue was when I uninstalled my app which resulted in all local preferences disappearing including the one holding the objectID. Suddenly all photos, settings that my testuser had uploaded was to waste. All set back to default and my query can no longer recognize the objectID no matter what I put in there.