Realm access from incorrect thread

后端 未结 4 2074
青春惊慌失措
青春惊慌失措 2020-12-06 09:35

I have an application with a LoginActivity, that when the user login correctly, I register to receive messages. And the LoginActivity jumps to

4条回答
  •  情话喂你
    2020-12-06 10:29

    Allocate instance before transaction and release it right after transaction is complete, so you won't have linegring connection and by doing so, you perform savings from thread scheduler. I use 'Data Access Object' interface for manipulations with data and that interface is implemented using Realm. Don't use 'transaction async', use all calls synchronously, but perform calls on 'data access object' from background thread. Good solution for that - rxJava library. Just get and release Realm instance all the time - library makes it inexpensive.

提交回复
热议问题