Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Parse: Can't update local user

I have a custom boolean field called Approved in my custom ParseUser object. We change this field from false to true via a web app. According to the documentation, I should be able to update currentUser after changing the flag with fetchInBackground(), like this:

ParseUser.getCurrentUser().fetchInBackground(new GetCallback<ParseObject>() {
    @Override
    public void done(ParseObject parseObject, ParseException e) {
        Log.v("qwer", "fetched User: " + ((CustomUser)parseObject).isApproved());
    }
});

But even though the approved flag has been set to true, the result coming back from the server is always false. Unless I logout and login again, at which point currentUser and the respective field is synced with the server.

Why doesn't fetchInBackground() work for the local user, and if I'm using it incorrectly, how do I update the currentUser.

like image 453
jwBurnside Avatar asked Apr 03 '16 03:04

jwBurnside


1 Answers

Please see this link, the point is to use pinInBackground and also enable local datastore with Parse.enableLocalDatastore(yourContext); in your Application class.


Update:

Not sure if this will help you, but I do have a similar situation with you:

I do a typical user.put("userVerified", true); then user.saveInBackground to save a boolean that indicates whether user has been verified, then in the next activity I use user.getBoolean("userVerified") to retrieve the flag...Would this be something you might consider?

like image 61
Joel Min Avatar answered Oct 11 '22 03:10

Joel Min