在Google云端硬盘应用文件夹中存储房间数据 [英] Store Room Database in Google Drive App Folder?

查看:178
本文介绍了在Google云端硬盘应用文件夹中存储房间数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还不熟悉房间和Google云端硬盘API和我想知道是否有可能创建一个房间数据库并将其存储在隐藏的Google云端硬盘应用程序文件夹中进行跨设备同步。如果任何人执行类似的事情,一个简短的例子会很棒。感谢!



编辑:

如何使用LiveData观察房间数据库中的某些变化,然后触发与Google Drive同步?

解决方案

即使有可能,它也可能无法可靠运行。 b

SQLite需要直接访问数据库的文件系统。房间没有改变。我从未使用Google Drive API,因此我不知道它是否允许您直接访问文件系统(例如, java.io.File )到内容。如果没有,那么您想要的是不可能的。



可靠性问题来自于Google Drive与您自己的应用程序不同。云端硬盘只能在您的应用没有主动使用数据库时使用该文件。我不知道Drive是否正在采取措施来确保这一点。否则,你可能会得到数据损坏。如果用户在云端硬盘完成任何同步工作之前修改了多个设备上的数据(例如,其中一个设备目前处于离线状态),那么您还会收到数据损坏。


I'm not yet familiar with Room and Google Drive API and I would like to know if it's possible to create a Room database and store it in the hidden Google Drive App folder for sync across devices. If anyone implemented something similar, a short example would be great. Thanks!

Edit:

What about using LiveData to observe when something changes in the Room database and then trigger a sync to Google Drive?

解决方案

Even if it is possible, it might not work reliably.

SQLite needs direct filesystem access to the database. Room does not change that. I have never used the Google Drive API, and so I do not know if it gives you direct filesystem access (e.g., java.io.File) to the content. If it does not, then what you want is not possible.

The reliability issue comes from the fact that Google Drive is a separate app from your own. Drive should only be working with the file when your app is not actively using the database. I do not know if Drive is taking any steps to ensure this. Otherwise, you could get data corruption. You will also get data corruption if the user modifies the data on multiple devices before Drive has done any sync work (e.g., one of the devices is presently offline).

这篇关于在Google云端硬盘应用文件夹中存储房间数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆