My understanding of the overarching problem is that you want to ensure that different instances of a base app use different firebase databases, but maybe I misunderstood.
Given that to create a different instance, you need to recompile the app to give it an app id, then the first solution proposed will work.
If all your apps have the same app id, then the second solution will work.
Trying to access multiple firebase accounts in the same app is discussed here:
I'm trying to subscribe to an FCM (Firebase Cloud Messaging) topic for a secondary Firebase App and according to the documentation this could be done by the overloaded getInstance which takes the
However, if you read through the solutions, you will see that the API used to make them work is deprecated.