Firebase database deleted when added app - java

Okay, so I am building an app that will go on the play store, it has the facility to add data to the Firebase (it cannot read it).
Second app will remain with me, (it wont go on the play store) and it is used to read the data.
Now what I did was, lets say the first app has package name : com.example.write and the second has com.example.read.
So I went to Firebase, created a project, added an application using the package name com.example.write and setup my first app. Working perfectly, I could add data to the Firebase database, now to create the second app, I created the android studio project, using the package name com.example.read and as both the apps use the same Firebase database, I added the new app in the same project in firebase, with package name com.example.read but then what I noticed was the previous database was deleted and when I hit the database button on the navigation bar, it gives me an option to create a database, when I do so, the first app crashes (probably because the old database was deleted to it could not add the data properly). So what should i do to use the same database on both the apps?
Using spark (free) plan of firebase!

So what should i do to use the same database on both the apps ?
To solve this, open Firebase Console, select your project, then click on Add another app and select Add Firebase to your Android app.
Provide all the necessary details for the new package name, in your case com.example.read, then download the JSON file again and add it to both of your android apps that are connected to this project. That's it!

Related

Disconnect Firebase from Android Studio

I am currently working on a project, this project is about an android application but it is currently on my friend's GitHub and it is currently connected to Firebase. I am not sure how to disconnect the project from Firebase. If someone could help that would be awesome. Please refer to this screenshot for further information:
Firebase Realtime Database is basically a Google program that hosts a database for you. In terms of being connected, generally we would be talking about a client connection to the host (the database). For that to happen you would have to be coding a program to connect to the database.
Are you talking about programmatically disconnecting the database? If not, I don't believe there's actually a connection there. It may just be Firebase telling you that you're on the right track to using the database in your program.
To double check that you aren't connected to the database, go in to your Firebase Console and double check that there isn't any usage happening on the Realtime Database. If there's not, I don't believe there's any connection you need to worry about.
Personally I've worked with Firebase before and used it in programs, and I've never come across a time when Firebase was anything other than a library or API for me to use. I doubt you need to worry!
If you're looking to delete the "App" on Firebase's end, you can go in to the Firebase Console and do that manually as well (to do this, you can go into your Apps card in the Firebase Console and select "Remove this app").
Furthermore, to delete the project itself in the Firebase Console, you can go to General Settings and click "Delete project".

Pass Data from android in home to android in office via online

I have a problem, I build an application for android that can open a single led with the use of bluetooth module and it succesfully works, now my problem is what if I want to open my led in my home while im at my office. What will I do is I will left another android that can open the led in my office and I will make another android application that will pass a data in my database and that data will retrieve by my android in my office and will trigger to open the LED.. I need tips on how I will gonna do that.. thanks
What you can do is have a realtime database like Firebase Realtime Database to store your data you need to communicate. So when a data is changed or updated your Phones will have the fresh data in sync. and then you can trigger changes accordingly
For eg, if the device in your office, clicks (Turn On LED), it will update the Firebase database with a value like (true), on the other side the device at your home would read the value, and check if the value is (true), then run the code to turn on the LED

Update Android App Database

So I got a simple app with a sqli database,
the app just shows the content which is saved in the database.
So if I am correct the sqli database is saved inside the app (apk),
what I am questioning myself is if I do have repeatedly upload the app / apk if I change, delete or add something in the database.
If yes is there a way around this, to like get the data from a database without repeatedly uploading the application if data has changed.
Yes, if you change something in the database you need to upload the apk, because the database is inside the apk. The alternative would be to put the database on a server. Then you would write a back end for your app in your language of choice, and this code would access the database. You could also use a Back End As a Service. Google BAAS to get info on the available options.

Registration in app right way

I am want to do registration in my app. So i have made all requests to my web service.
I now when user is registered.
Now i need to save somewhere that he is registered that don't give him registration form again.
How to do this ?
Do i need to save somewhere in my sqlite database and every time when app lunches check if he is registered user. Or maybe in app settings i could save this information.
I am new to developing android app and i am searching for the right way.
Thanks all for help.
You could save that with SharedPreferences. Check the link for sample code.
http://developer.android.com/guide/topics/data/data-storage.html#pref.
This data will be removed if the users uninstalls the app or clears all data from system menu.
Edit: If you really want to remember preferences across installs you should try Backup API. http://developer.android.com/guide/topics/data/backup.html
The best solution is to use Android's Account Manager to handle user account. This aproach is the most secure (credentials are not exposed), however it has two drawbacks:
It's a little bit complocated to set up
It requires at least API version 5
Once the user registered you can save in your sqlite database and you have to check for each time when your application launches. But if the user uninstalled the application and tried to reinstall it ll ask for registration again.. In order to avoid this you have to store the information like the device id and the registered details in some servers and also in sqlite database and have to check when the application launches...

Synchronize and Update database android application from website

I have problems.
I create an application which is on starting it will synchronize the database in external storage with database on website if any data changed it will appear dialog to ask "Do u want update".
I put my database on website http://example.com/folder/mydb.db
and for android I put it on external at data/data/database/mydb
How to check any database changed?
Change the name of the file you upload, adding the version number so you can just compare the file name to check for modification.
If different, download and override your existing DB using the tutorial here:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Categories