How to use Realm for Android like a champ, and how to tell if you’re doing it wrong
Gabor Varadi
1.3K27

Thanks for the article, you pointed a lot of mistakes I make.

The first mistake I do is having a single realm instance carried around the whole app and injected via dagger where I need it. For what I understand I should not do that, and instead open and close them.

But I am a bit confused regarding threads and realm. My understanding is that I cannot use a realm object that came from a different thread on the UI thread. So should I separate the write to realm operations into a background thread and do the read from realm operations on the UI thread? Rather than write to realm on the UI thread and use the created object directly.