Realm – Share databases between applications
So I have an app consisting of 3 APKs/apps. How do I share a database between applications? The reason I’m assuming it’s not currently visible between applications is because they’re passed in different contexts.
Here’s Christian from Realm.
What you’re asking is really not feasible at the moment. As others have pointed out, there are really only two ways.
1) Expose a ContentProvider. However, this requires you to map RealmResults to Cursor, which is not an easy task. We plan to make a RealmCursor public offline, but other things have priority, so we haven’t looked at the details yet.
2) Put the Realm database in a shared location and let the application read from there. This sounds like an easy approach, but unfortunately, Realm doesn’t yet support multi-process (multiple applications need to have the same Realm file open at the same time). So now you must implement a locking scheme in your app so that they can decide who can open the file.
So now, the answer is: you can, but it requires a lot of skill, so it’s not recommended. On the positive side, we are aware of this, at least ATMs are actively supporting multi-process.