android - Parse.com hangle one-to-many relation -


i need save one-to-many relations in parse, every cathegory has have several questions ( max 4 ) , every question has have string question , answer ( max 5 strings ) , additionally 4 image ( not implemented yet ) , need have online updating "on air". , testing database service ( , decided parse need save relation between cathegory , question)

this code activity (fragment) :

            question q1 = new question("how money cost new skoda fabia?", "300 " +                     "000kc", "200 000kc", "100 000kc", "50 000kc");             q1.saveinbackground();             question q2 = new question("how money cost new skoda felicia?", "300 " +                     "000kc", "200 000kc", "100 000kc", "150 000kc");             q2.saveinbackground();             question q3 = new question("how money cost new skoda octavia?", "500 " +                     "000kc", "150 000kc", "100 000kc", "50 000kc");             q3.saveinbackground();              arraylist<question> questionarraylist = new arraylist<>();             questionarraylist.add(q1);             questionarraylist.add(q2);             questionarraylist.add(q3);              parseobject parseobject = new parseobject("cathegory");             parseobject.put("auto", questionarraylist);             parseobject.saveinbackground(new savecallback() {                 @override                 public void done(parseexception e) {                     log.d(tag,"save sucesfully");                     log.d(tag,"error ? : " + (e == null ? "none" : e.getmessage()));                 }             }); 

category created correctly if @ questions there : parse problem image

question class code:

  @parseclassname("question") public class question extends parseobject { public static final string tag = question.class.getname();  private string question; private string rightanswer; private string wronganswer1; private string wronganswer2; private string wronganswer3;  public question(){     //need parse }  public question(string question, string rightanswer, string wronganswer1, string wronganswer2, string wronganswer3) {     super();     this.question = question;     this.rightanswer = rightanswer;     this.wronganswer1 = wronganswer1;     this.wronganswer2 = wronganswer2;     this.wronganswer3 = wronganswer3; }  public question(string theclassname, string question, string rightanswer, string wronganswer1, string wronganswer2, string wronganswer3) {     super(theclassname);     this.question = question;     this.rightanswer = rightanswer;     this.wronganswer1 = wronganswer1;     this.wronganswer2 = wronganswer2;     this.wronganswer3 = wronganswer3; } 

}

dumb mistake. please aware of this.

right code of question class :

 @parseclassname("question") public class question extends parseobject { public static final string tag = question.class.getname();  private string question; private string rightanswer; private string wronganswer1; private string wronganswer2; private string wronganswer3;  public question(){     //need parse }  public question(string question, string rightanswer, string wronganswer1, string wronganswer2, string wronganswer3) {     super();     super.put("question", question);     super.put("rightanswer", rightanswer);     super.put("wronganswer1", wronganswer1);     super.put("wronganswer2", wronganswer2);     super.put("wronganswer3", wronganswer3);     this.question = question;     this.rightanswer = rightanswer;     this.wronganswer1 = wronganswer1;     this.wronganswer2 = wronganswer2;     this.wronganswer3 = wronganswer3; }  public question(string theclassname, string question, string rightanswer, string wronganswer1, string wronganswer2, string wronganswer3) {     super(theclassname);     super.put("question", question);     super.put("rightanswer", rightanswer);     super.put("wronganswer1", wronganswer1);     super.put("wronganswer2", wronganswer2);     super.put("wronganswer3", wronganswer3);     this.question = question;     this.rightanswer = rightanswer;     this.wronganswer1 = wronganswer1;     this.wronganswer2 = wronganswer2;     this.wronganswer3 = wronganswer3; } 

}


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -