1

Can't create a new row in using Parse in android. I am able to retrieve, but when I try to add a new row like this, I keep getting false and new row is not being created.

What am I doing wrong here ? I am exactly following what is given in Parse-Android documentation.

ParseObject storyActivity = new ParseObject("StoryActivity");
storyActivity.put("createdByUser", user);
storyActivity.put("story", story);
storyActivity.put("type", likeUnlike);
return storyActivity.saveInBackground().isCompleted();
4
  • 3
    Parse is shutting down in 2017. If your project isn't for learning purpose probably you should switch now. It would be difficult later. Commented Jan 29, 2016 at 13:55
  • If you can't create any rows, then how come there already exist data? Commented Jan 29, 2016 at 13:55
  • @4k3R : I am trying to add data into the empty table StoryActivity Commented Jan 29, 2016 at 13:57
  • @Rohit5k2 This is for learning purposes. Thanks for the info :) Commented Jan 29, 2016 at 13:59

3 Answers 3

1

Check class level permission Write under class StoryActivity's Security on console.

Sign up to request clarification or add additional context in comments.

1 Comment

I did not have security access! I have enabled write access and it works !
0

Call that in following way -

ParseObject storyActivity = new ParseObject("StoryActivity");
storyActivity.put("createdByUser", user);
storyActivity.put("story", story);
storyActivity.put("type", likeUnlike);
 storyActivity.saveInBackground(new SaveCallback() {
   public void done(ParseException e) {
     if (e == null) {
       // your object is successfully created.
     } else {
       //error occurred
       Toast.makeText( context,e.getMessage().toString(),Toast.LENGTH_LONG );
     }
   }
 });

So, by this toast message you can know what is reason of problem you are getting.

Comments

0

Try on this way to set read write permission when user insert/ update record in parse database like ...

ParseObject storyActivity = new ParseObject("StoryActivity");
    storyActivity.put("createdByUser", user);
    storyActivity.put("story", story);
    storyActivity.put("type", likeUnlike);

    // here first set read write permission like ..
    // when user update value ya insert new value in database
    ParseACL postACL = new ParseACL(ParseUser.getCurrentUser());
    postACL.setPublicReadAccess(true);
    postACL.setPublicWriteAccess(true);
    storyActivity.setACL(postACL);

    storyActivity.saveInBackground(new SaveCallback() {

        @Override
        public void done(ParseException e) {
            // TODO Auto-generated method stub
            if (e == null) {
                // success
            } else {
                // fail
                Log.e("Tag", "getting to fail " + e.getMessage());
            }
        }
    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.