Juhani Juhani - 7 months ago 144
Android Question

IllegalStateException for RealmObject after copyFromRealm

I'm getting this exception:

java.lang.IllegalStateException: This Realm instance has already been closed, making it unusable.


when calling an accessor of an object even after the object has been detached from Realm with
realm.copyFromRealm()
.

My understanding of the Realm documentation was that once I copy the object from Realm it no longer run the state validations or require open realm connection.

Any ideas what could be the cause?

Answer

It is hard to say without seeing some code, but are you sure you are accessing the object returned from copyFromRealm and you are not still accessing the original object?