Start a new topic

problem with User update

I'm trying to add new items to the User class.

The documentation says to do the following



User user = kinveyClient.user();

user.put("fav_food", "bacon");

user.update(new KinveyClientCallback() {

public void onFailure(Throwable e) { ...

public void onSuccess(User u) { ... }

});

}



The user.update doesn't seem to actually exist in the android environment. I see a method called Update but that doesn't seem to want to compile.

I have the latest lib files from the download zip Kinvey-2.6.14.zip.



What am I doing wrong?



I tried several other ways:



User user = mKinvey.user(); //

user.put("estup", "abc");

User.Update updateReturn = null;

try{

updateReturn = user.updateBlocking(user); // also update = user.updateBlocking();

updatereturn.execute();

}

catch (Exception e){

}



This code throws an error (null pointer exception). On the user.updateBlocking() call.



Any ideas?



1 Comment

Hey,



The android library provides two variations of each method-- there is a synchronous `blocking` variation as well as an asynchronous one. All of the methods that require a `Callback` (of any type) are part of the asynchronous library. Note that the async variations all extends the sync one, so both method signatures are available.



When getting a reference to the user object from the Client, get it as an `AsyncUser` instead of just `User`. Also, the library has a `KinveyUserCallback`, which is the same thing as a `KinveyClientCallback`, it just a convenient wrapper class.



AsyncUser user = kinveyClient.user();

user.put("fav_food", "bacon");

user.update(new KinveyUserCallback() {

public void onFailure(Throwable e) { ... }

public void onSuccess(User u) { ... }

});

Login or Signup to post a comment