I'm new to realm and trying to delete the entire realm database after logout. I want to check if any realm instances is running or not before deleting the database.
Asked
Active
Viewed 2,131 times
1 Answers
8
You can use Realm.getGlobalInstanceCount(config) to see how many threads there are open Realms on,
and you can use Realm.getLocalInstanceCount(config) to see how many local Realm instances are there open on this current thread.
If globalInstance == 0
then no Realm is open on any thread.

EpicPandaForce
- 79,669
- 27
- 256
- 428
-
Is there a way to get the list of local instances? We have 2 instances that are left open, however none are coming from a Realm.getInstance() in our code !? – 3c71 Jun 12 '23 at 11:14
-
@3c71 i think you can only see the count – EpicPandaForce Jun 12 '23 at 11:48