crash - Realm for Android crashes when adding item to RealmList -


i'm using realm android develop collections-based app storing different data types. collection data structure scrapbook has properties , maintains lists of other types of realmobjects in many-to-many relationships (ie objects can belong more 1 scrapbook).

when creating scrapbooks, i'm having no problems creating , adding item called tag list, yet when i'm retrieving scrapbooks elsewhere , trying add new objects different list it's crashing.

in activity designed create item called spendscrap, user has selected scrapbooks checkbox dialog maintained activity in arraylist<scrapbook>. on button click, realm instructed create item , add scrapbooks.

//---inside button.onclicklistener()---// realm.executetransactionasync(new realm.transaction() {                     @override                     public void execute(realm realm)                     {                         spendscrap scrap = realm.createobject(spendscrap.class);                         scrap.setname("test");                         scrap.setvalue(11.99);                          (scrapbook s : selectedscrapbooks)                         {                             s.spendlist.add(scrap);                         }                     }                 }, new realm.transaction.onsuccess()                 {                     @override                     public void onsuccess() {                         finish();                     }                 }); 

here scrapbook.class

public class scrapbook extends realmobject {     private string name;        // name      private date datecreated;   // date scrapbook registered     private int colour;      // colour used sort scrapbook     public realmlist<tag> taglist; // dem tags it's been tagged      public realmlist<spendscrap> spendlist; // spends has      /**      * returns name      * @return      */     public string getname() {         return name;     }      public void settaglist(realmlist<tag> taglist) {         this.taglist = taglist;     }      public realmlist<spendscrap> getspendlist() {         return spendlist;     }      public void setspendlist(realmlist<spendscrap> spendlist) {         this.spendlist = spendlist;     }      /**      * sets name      * @param name      */     public void setname(string name) {         this.name = name;     }      /**      * returns date created      * @return      */     public date getdatecreated() {         return datecreated;     }      /**      * returns colour string      * @return      */     public int getcolour() {         return colour;     }      /**      * sets colopur      * @param colour      */     public void setcolour(int colour) {         this.colour = colour;     }      /**      * sets date (expects date object)      * @param datecreated      */     public void setdatecreated(date datecreated) {         this.datecreated = datecreated;     }      /**      * adds tag database      * @param tag      */     public void addtag(tag tag)     {         this.taglist.add(tag);     }      /**      * returns tag list      * @return      */     public realmlist<tag> gettaglist()     {         return this.taglist;     } } 

and here spendscrap.class

public class spendscrap extends realmobject {     private string name;     private double value;      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public double getvalue() {         return value;     }      public void setvalue(double value) {         this.value = value;     } } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -