Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Using Room and Firestore?

I wrote an app that saves and uses data in/from a Cloud Firestore database. I would want to organize more clearly than for the moment my files, for example by using DOs and DAOs.

I know the concept of "DAO" exists in Android Room.

However, the documentation seems to define Android Room as a "local database". So if I understand it well, I shouldn't use it in addition to Firestore?

By the way, it would be the same with Firebase Cloud Realtime Database (a third database system).

Edit :

I didn't understand the notion of "local" database (Room). Tamir, in his answer, corrected me. This question is off-topic.

like image 900
JarsOfJam-Scheduler Avatar asked Feb 23 '19 15:02

JarsOfJam-Scheduler


2 Answers

So if I understand it well, I shouldn't use it in addition to Firestore?

No and this is beacause Cloud Firestore has offline persistence enabled by default:

For Android and iOS, offline persistence is enabled by default. To disable persistence, set the PersistenceEnabled option to false.

This means that you'll have by default a local copy of your database. So there is no need to add another one.

like image 97
Alex Mamo Avatar answered Sep 21 '22 18:09

Alex Mamo


Basically, when you are developing an app there would be some data that you will want to save into locally and other data that you will want to save on remote database, it's not a bad thing to have both remote and local database.

Some example that I can think of for saving your data remotely is to manage users - when a new user will be created you will want to check if the username is not taken, and you can't do it if this data is only stored locally.

And for using a local database - one of the major advantages in the local database vs remote database its the speed of writing and receiving data.

Here is a nice article on the subject.

like image 20
Tamir Abutbul Avatar answered Sep 20 '22 18:09

Tamir Abutbul