view raw
Mark Swedish Mark Swedish - 9 months ago 321
Java Question

java.lang.IllegalStateException whenever I try to add values into a populated RealmList<MyObject>

I'm trying to add new items insedi a RealmList but I'm getting this error :

Changing Realm data can only be done from inside a transaction.

Do you know why it is happening?

Thanks in advance!


You should be inside a Realm Transaction to add a new item in this list. The fllowing code si an example how to do it:

    RealmQuery query = realm.where(YourClass.class);
    RealmResults results = query.findAll();

I hope it can be helpful.