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:
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:
By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache.
Note: Offline persistence is supported only in Android, Apple, and web apps. To use offline persistence, you don't need to make any changes to the code that you use to access Cloud Firestore data.
Firestore supports offline data persistence. This feature caches a copy of the Firestore data that your app is actively using, so your app can access the data when the device is offline. You can write, read, listen to, and query the cached data.
Firebase Realtime database is stuctured as a JSON tree while Cloud Firestore stores data in documents (document is a set of key-value pairs) and collections (collections of documents). Realtime Database stores data in JSON tree while Cloud firestore stores data in documents which is very similar to JSON.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With