0

In my AppCombatActivity.. I can successfully query for the parse object. However, when I use object.put("Key", value) and object.saveinBackground(); inside a button click The items don't get saved.

    userFeedItem = new ParseQuery<ParseObject>("FeedItem");
    userFeedItem.whereEqualTo("username", feedUserName);
    userFeedItem.whereEqualTo("textItem", feedItem);
    userFeedItem.findInBackground(new FindCallback<ParseObject>() {
     @Override
        public void done(List<ParseObject> objects, ParseException e) {
            if (e == null) {
                for (final ParseObject mObject : objects) {


                    likes = mObject.getInt("likes"); //value is retrieved successfully
                    Log.i("yo", "1) BEFORE: Object , likes:   " + mObject.getString("username") + "  , " + likes); //log shows correct values

              }
  });

                    upVoteButton.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                        //No `mObject.get` methods shown but I can access those values from Parse from here

                        likes += 1;
                        Log.i("", """); //log succesfull increments value
                        mObject.put("likes", likes);
                        mObject.saveInBackground();    //The put value doesn't save!

                   }
              });
grantespo
  • 2,233
  • 2
  • 24
  • 62
  • refer http://stackoverflow.com/questions/24897231/saveinbackground-callback-doesnt-work – sasikumar Dec 04 '16 at 05:45
  • I deleted my class and let Android call it, However, that didn't work. – grantespo Dec 04 '16 at 05:47
  • Interesting, `SaveInBackGround` works in the query for the parse object. But it doesn't work in the OnClickListener – grantespo Dec 04 '16 at 06:01
  • 1
    Hope you are thinking of other options as well, since Parse is being discontinued in less than 2 months from now http://blog.parse.com/announcements/moving-on/ – SoulRayder Dec 04 '16 at 06:32
  • I am using Parse-Server with Heroku. @SoulRayder – grantespo Dec 04 '16 at 06:41
  • Have you check the error message? Once success, this object.getId will not empty. If you failed, check your DB class permission and the beforeSave hook is passed. – ChunTingLin Dec 04 '16 at 12:03
  • I'm not sure what the error was, I ended up re-coding the whole class Identically from how It looked before. But it works now. – grantespo Dec 04 '16 at 12:20

0 Answers0