1

I am new to parse SDK services using Android Studio and I have to ask that how to store more than one row in parse database . I am using back4app parse server whenever I want to put data on data base I.e more than one row then it does not store the first row but the second one as from the code below

ParseObject obj = new ParseObject("Table");
obj.put("Name","John");
obj.put("Score","40");
obj.put("Name","Jack");
obj.put("Score","50");
obj.saveInBackground();

So when I run app then only name and score for Jack stored in database creating one row and I want rows for both John and Jack, Kindly help me resolving this issue

rici
  • 234,347
  • 28
  • 237
  • 341
Adnan Butt
  • 47
  • 3

1 Answers1

0

You override your object fields ("name" and "score"), i.e. you delete John before save. Make a method that save your person:

private void savePerson(String name, String score){
    ParseObject obj = new ParseObject("Table");
    obj.put("Name",name);
    obj.put("Score",score);
    obj.saveInBackground();
}

and in code where you want to save person, call created method to do that:

savePerson("John", "40");
savePerson("Jack", "50);
miljon
  • 2,611
  • 1
  • 16
  • 19
  • Hey miljon first of all thanks for your reply but I watched in Rob Percival's android tutorial he saved with the same code as I mentioned in question and he got both rows at the same time as he executed the app and please describe the second approach you told me to do – Adnan Butt May 05 '17 at 10:52
  • Well you did something wrong if he did it and Its not working in your code ;) Still you override values.. Make a method to save a person and then just call it when you want to save a person, I edited answer look at it.. – miljon May 05 '17 at 11:03