Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link Android Room Database with Firebase Realtime Database

Tags:

I am using Android Room Database for creating the database for my android app. It works perfectly for me locally but I cannot link to a server to have it online as well. I am using Firebase for Authentication. I am trying to use Firebase Realtime Database to save the whole database object from Room and load the correct database on app startup according to the authenticated user.

I want to ask if this is possible at all? and if I can just save a whole instance of Room database or I need to re-create the database on Firebase and save my data item by item?

I also can't seem to be able to get access to the database data of Room, as when I get an object of the AppDatabase class it doesn't really pass the data. And I don't know how should do the opposite, to assign the data retrieved from Firebase later to the local data saved?

Also if it's not possible with Firebase, do you have any recommendation for some other server I can use with Room?

like image 306
Pierre Ghaly Avatar asked Apr 23 '18 01:04

Pierre Ghaly


People also ask

Can I use both Realtime Database and firestore?

You can use both Firebase Realtime Database and Cloud Firestore in your app, and leverage each database solution's benefits to fit your needs. For example, you might want to leverage Realtime Database's support for presence, as outlined in Build Presence in Cloud Firestore.


1 Answers

After a lot of researches and looking desperately for an answer here's what I reached:

  • Firebase already got a straight forward way to create the database and host it online. (I had my database already created so was trying to save time, but creating it from scratch using Firebase Realtime Database was a lot faster)
  • Room Database is quite perfect if you are planning to save your database locally and offline (Up to the post date)
like image 176
Pierre Ghaly Avatar answered Sep 18 '22 08:09

Pierre Ghaly