Android implementation with Realm DB, transactions on main UI Error

Viewed 3044

I am implementing an instance of the Realm Database within the android application I am designing. However, at first I got this error about Realm transactions on main UI thread:

Running transactions on the UI thread has been disabled. It can be enabled by setting 'RealmConfiguration.Builder.allowWritesOnUiThread(true)'.

I enabled the setting mentioned above, but the error persisted. I decided to implement an AsyncTask class in order to try to execute the realm transaction within the doinbackground method (which runs on a separate thread) but i am still getting the same error.

Can you offer me some advice on how I should proceed?

kind regards, Lampros

2 Answers

Are you actually building a Realm configuration object after you call allowWritesOnUiThread(true) and using it to retrieve your Realm instance?

I know this is late but was able to resolve this by changing realm.execute to realm.executeTransactionAsync instead of setting allowWritesOnUiThread(true).

Related