When developing an Android app, when trying to update data using Realm
,
Cannot modify managed objects outside of a write transaction. Error was output.
The database has been updated outside the transaction.
...
DB update process
...
realm.beginTransaction()
realm.copyToRealmOrUpdate(DB)
realm.commitTransaction()
Simply put Multiple processes that require consistency of results.
When a transaction is separated, it becomes inconsistent and the transaction fails even though the transaction needs to be successful.
Perform update processing within a transaction.
realm.beginTransaction()
...
DB update process
...
realm.copyToRealmOrUpdate(DB)
realm.commitTransaction()
What is a "transaction"? I tried to talk about it in a super easy way!