14

I have an App where a main Feature is "Offline Usage".

We generate a SQLite-Database on our Server what we provide on an API for download. Each time the Database has changed, the users had to redownload the Complete SQLite-Database (Which is currently 50MB and growing in time).

We tried to improve the Update-Method that the user only had to download the Difference-SQL files, but there are some problems (Performance, Corrupt Databases, etc).

Now Google Released Firebase and I thinks it's a good time to replace the SQLite-System with the Firebase System.

But I have some thoughts:

  • Can I download the entire Firebase Database for Offline Usage (Not in an App-Cache, in a persistent Storage)?
  • Can I track the Progress of the Offline Sync and give the User the option if he want's to sync now or later?
  • Can I restrict the Sync to WIFI only?
  • Can I deliver a Bundle Database - that after installing the App I can already query offline-Firebase Data?

What I want is: Using Firebase in my App only to sync the Databases - BUT perform all Operations offline. If Firebase is not designed to use this, what's a good alternative?

Then I've another main question regarding Firebase:

  • JSON Storage is great - but this way we don't care about a unique Structure, we must pay attention on this to insert always correct Datasets?
AL.
  • 36,815
  • 10
  • 142
  • 281
brokedid
  • 879
  • 2
  • 10
  • 35

1 Answers1

6

Can I download the entire Firebase Database for Offline Usage (Not in an App-Cache, in a persistent Storage)?

Yes you can do this by setting disk persistence to true. You just need to reference the highest level in the database and firebase will return all child nodes. https://firebase.google.com/docs/database/android/offline-capabilities

Can I track the Progress of the Offline Sync and give the User the option if he want's to sync now or later?

I have never tried to show the actual progress, however when you retrieve data from firebase there is always the onDataChange method that gets called when you have succesfully retrieved data. https://firebase.google.com/docs/database/android/retrieve-data#read_data_once

Can I restrict the Sync to WIFI only?

I have not seen this option in the Firebase documentation, however I do not believe it would be very difficult to implement

Can I deliver a Bundle Database - that after installing the App I can already query offline-Firebase Data?

You would need to grab data from Firebase as soon as the App is installed. You could also in theory when the app is first run try to write to the Firebase database without any network and then this data could be available locally, however you would need to be careful as when the user gets a network connection then this data might overwrite the data in the Firebase database. How do I cache Firebase data for offline usage?

Community
  • 1
  • 1
Riley MacDonald
  • 453
  • 1
  • 4
  • 15
  • Thanks for the answer! Do you know also the last question about the data structure & can provide me more details of the download Progress of a query if I download the entire Database and if I can detect if the Database differs from the online Version....? – brokedid Sep 28 '16 at 10:50
  • Are there any news? Still the same or can we do that better now? – brokedid Sep 14 '17 at 11:30