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.
Thanks
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.
Thanks
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) 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) 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.
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.
I don't think sharing an same database is possible , but you can try these ways:
This blog post explains how support for this is implemented on iOS and has the following key information at the bottom.
You can use Inter-Process Communication in Realm Swift v0.92 onwards (download the latest version, or read the docs), and Realm Objective-C v0.91 onwards (download the latest version, or read the docs).
I'm afraid I don't know the Android status.