领域 - 应用程序之间共享数据库 [英] Realm - Share Database between Apps

查看:135
本文介绍了领域 - 应用程序之间共享数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个由3个APK /应用程序组成的应用程序。如何在应用程序之间共享数据库?

So I have a application that is comprised of 3 APK/Apps. How do I share the database between apps? I am assuming the reason it is currently not visible between the apps is because they are passing in different contexts.

感谢

推荐答案

Christian来自Realm here。
目前你要的是真的不可行。正如其他人指出的,真的只有两种方法。

Christian from Realm here. Currently what you are asking is really not feasible. As others have pointed out there is really only two approaches.

1)公开一个ContentProvider。然而,这需要你映射RealmResults到一个不是微不足道的努力的游标。我们计划将RealmCursor下线,但其他事情已经优先,所以我们还没有看到细节。

1) Expose a ContentProvider. However that require you to map RealmResults to a Cursor which is not a trivial effort. We are planning on exposing a RealmCursor down the line, but other things have had priority so we havn't looked at the details yet.

2)把Realm数据库放在共享位置,并让应用从那里读取。这听起来像一个简单的方法,但不幸的是,Realm不支持多个进程(多个应用程序需要同时打开相同的Realm文件)。所以现在你必须在应用程序中实现一个锁定方案,以便他们可以决定谁可以打开该文件。

2) Put the Realm database in a shared location and let the apps read from there. This sounds like an easy approach, but unfortunately Realm doesn't support multiple processes yet (which would be required for multiple apps to have the same Realm file open at the same time). So right now you would have to implement a locking scheme in your apps so they can decide who can open the file.

现在,答案是:你排序可以,但它需要很多hack,所以不是真的推荐。积极的一面是,我们意识到这一点,并且至少多进程支持正在积极地在atm工作。

So right now, the the answer is: You sorta can, but it require a lot of hacks, so is not really recommended. On the positive side, we are aware of this and at least multiprocess support are actively being worked on atm.

这篇关于领域 - 应用程序之间共享数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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