Mark Swedish Mark Swedish - 1 year ago 412
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!

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download