Android Question Can one app use multiple firebase databases?

Gentry

Member
Licensed User
Longtime User
I would like to partition my app user data into separate firebase databases (due to discrete regional activity), but I'd like to only have a single app and change the database target programmatically. The data is secured behind firebase auth (google currently) but I am considering starting with anonymous with optional google auth.

Since the firebase functions rely on the google-services.json for a specific fb database, it seems that only one firebase target would be available per app.

If there a way around this? can multiple google-services.json content be concatenated in a single file and the app choose which target to utilize?

Is it possible to manipulate the google-services project data at runtime?

I also have a use case where I would allow the app user to target their own personal firebase databases, user supplied if you will.

Reference:

https://firebase.googleblog.com/201...iple-firebase-projects-in-an-android-app.html
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
it seems that only one firebase target would be available per app
right. You even do not need to know the databasename as Firebase already know the Database behind your app-signature.
can multiple google-services.json content be concatenated in a single file and the app choose which target to utilize?
Yes and no.

Yes, you can download your Firebase-projects-json. Inside your project you can have multiple apps. Each of them are listed in the json.
But only the packagename at compiletime is important. The Manifestsnippets extract the right values for your app from the json.

No, you can not have multiple connections from ONE App (packagename). BUT you maybe able to use the http-rest-api for Firebase to connect to another database.

Is it possible to manipulate the google-services project data at runtime?
No, the extracting of values are happening at Compiletime based on the apps packagename.
 
Upvote 0

Gentry

Member
Licensed User
Longtime User
Thanks for the unfortunate confirmation. Now i'm wondering if anonymous sign-in happens against a firebase db without any explicit action from the app required. I'm going to guess there would be mismatch error from the google-services.json regardless.

Going to try to skin the cat a different way I suppose.
 
Upvote 0
Top