本文介绍了Firebase离线存储高级 - 手动同步和进度信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我们有一个应用程序,其中一个主要功能是离线使用。 我们在我们的服务器上生成一个SQLite数据库,我们提供了一个API供下载。每次数据库发生变化,用户都必须重新下载完整的SQLite数据库(目前为50MB,并且正在增长)。 我们试图改进Update-方法,用户只需要下载差异SQL文件,但有一些问题(性能,损坏的数据库等)。 现在谷歌发布的Firebase和我认为 但是我有一些想法: 使用Firebase系统替换SQLite系统是个好时机。 > 我可以下载整个Firebase数据库以进行脱机使用吗(不是在应用程序缓存中,而是在持久性存储中)? 我可以跟踪离线同步,并给予用户选择,如果他想同步现在或以后? 我可以限制同步到WIFI吗? 提供捆绑数据库 - 在安装应用程序后,我已经可以离线查询Firebase数据了? 我想要的是 :在我的应用程序中使用Firebase只能同步数据库 - 但是离线执行所有操作。如果Firebase没有设计使用这个,那么有什么好的选择?然后,我还有一个关于Firebase的主要问题: JSON存储是伟大的 - 但是这样我们不关心一个独特的结构,我们必须注意这个插入总是正确的数据集? 解决方案 我可以下载整个Firebase数据库以供离线使用缓存,在一个持久存储)? 是的,您可以通过将磁盘持久性设置为true来执行此操作。您只需引用数据库中的最高级别,并且firebase将返回所有子节点。 https://firebase.google.com/docs/database/ android / offline-capabilities 我可以跟踪离线同步的进度,并为用户提供选项如果他想现在或以后同步? 我从来没有试图显示实际的进度,但是当你从firebase检索数据始终是您成功检索数据时调用的onDataChange方法。 https://firebase.google.com/docs/我可以限制同步到WIFI吗?$ / b> 我还没有在Firebase文档中看到这个选项,但是我不相信实现它会非常困难 我可以提供捆绑数据库 - 在安装应用程序之后,我可以已经离线查询 - Firebase数据吗? 只要App安装完成,您就需要从Firebase获取数据。您也可以在理论上初次运行应用程序时尝试写入Firebase数据库,而不使用任何网络,然后可以在本地使用这些数据,但是您需要小心,因为用户获得网络连接时可能会覆盖此数据Firebase数据库中的数据。 如何将Firebase数据缓存为离线使用? 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? 解决方案 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? 这篇关于Firebase离线存储高级 - 手动同步和进度信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 05:57