I created an Android app with package name 'com.theapp.app1' initially when setting up my Firebase for the first time. But later I decided to change my app name from 'com.theapp.app1 to 'com.theapp.app2'. I refactored my package name in Android Studio but got an error 'Gradle does not recognize 'com.theapp.app2' in google-services.json file.
In app1 I have created a json database which I want to copy to app2 in firebase without re-creating a new database in app2. Plus, I want to delete app1 after copying its db content.
I tried renaming the app1 name to app2 in firebase but I figured out that it is impossible.
Is there a way to achieve this without the need to create a new json database in Firebase?
I think i can answer my question. #has9 suggestions helped me figure out that the Json database is not directly tied to an app on firebase. that is, when you create another app (app2) and delete app1, your database will not be deleted with app1. i hope i explained my answer clearly. anyways this solved my problem.
Related
I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:
[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]
I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
There are two possible solutions:
Download an updated google-services.json from the Firebase console, and add that to your Android app.
Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
Both have the same result, so pick whichever one seems easiest to you.
It cat still not work after the accepted answer (as in my case). If so, try:
Clean Project
Rebuild Project
Invalidate Caches & Restarte
and run it again.
If you are a New Flutter User who followed the new firebase doc, run this command in the terminal. It will automatically update the firebase_options.dart file.
flutterfire configure
I faced the same problem and that's because when you set up the app, the google-service.json doesn't contain the firebase_url.
These problems faced you when configuring your set up manually, You can fix all that problems by using flutterfire, it will help you a lot and set up your app in a few steps.
see docs firebase
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases, the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
You can fix it either way.
After configuring the database service setup you have to download the new "GoogleService-Info.plist" file and replace the previous one.
or
You can manually set the key in your "GoogleService-Info.plist" file
<key>DATABASE_URL</key>
<string>https://<app-instance-default-rtdb>.asia-southeast1.firebasedatabase.app</string> '
I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:
[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]
I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
There are two possible solutions:
Download an updated google-services.json from the Firebase console, and add that to your Android app.
Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
Both have the same result, so pick whichever one seems easiest to you.
It cat still not work after the accepted answer (as in my case). If so, try:
Clean Project
Rebuild Project
Invalidate Caches & Restarte
and run it again.
If you are a New Flutter User who followed the new firebase doc, run this command in the terminal. It will automatically update the firebase_options.dart file.
flutterfire configure
I faced the same problem and that's because when you set up the app, the google-service.json doesn't contain the firebase_url.
These problems faced you when configuring your set up manually, You can fix all that problems by using flutterfire, it will help you a lot and set up your app in a few steps.
see docs firebase
It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases, the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.
You can fix it either way.
After configuring the database service setup you have to download the new "GoogleService-Info.plist" file and replace the previous one.
or
You can manually set the key in your "GoogleService-Info.plist" file
<key>DATABASE_URL</key>
<string>https://<app-instance-default-rtdb>.asia-southeast1.firebasedatabase.app</string> '
I've set-up up my AS to use Firebase. How to know/change the Firebase app/Database I'm using in my app from Android Studio?
If you have already setted your project, you must have downloaded a google-services.json and put it in the app folder. So, in that json, you can find your database url.
I developed an Android application that works on sqlite internal db.
Now I want create a new android application that clean the database of my first application.
What can I do?
Let the second application send a intent broadcast, after receiving the broadcast, let the first application can clear the data. But any application cannot clear another application's data, even if it is possible, it is not elegant.
I believe you can do it if you modify the manifest of both apps to make them share the same data directory.
Add the android:sharedUserId property to the manifest of each app.
android:sharedUserId="your.shared.id"
If they are the same and you sign them with the same key & alias, each of the appa can use/access the others private directories.
Hello
In my android application when the user reinstall the app again i would like to delete the existing database and create a fresh new one.
How could i know that the user is reinstalling the app or is quering for the updates request.
How could i delete a file in raw folder?
Please share your valuable suggestions.
Thanks in advance:)
Hello In my android application when the user reinstall the app again i would like to delete the existing database and create a fresh new one.
If by "reinstall", you mean "uninstall and reinstall", your existing database will be deleted during the uninstall process, assuming it resides in the normal database location (i.e., not on external storage).
How could i know that the user is reinstalling the app
You don't.
How could i delete a file in raw folder?
In Android? You don't. Resources cannot be modified or removed at runtime.
Reinstalling application deletes all data for the application. If you mean reinstalling is upgrading then you can observe the new version number in the SQLiteOpenHelper.onUpgrade() method.
To delete the database file, it is explained here (Database Delete Android).