Reputation: 329
I have 2 different applications:
1) Admin (create, edit, delete data) 2) User (View only)
What i'm trying to achieve is to share the database created from Admin to User
I am also planning to share the data to other user app installed in other device.
The database I am using is Realm
How can I achieve that? Should I extract the database from Admin and dump it to user? If so, how is it done?
Thank you!
Upvotes: 0
Views: 445
Reputation: 1787
Assuming both apps are developed by the same developer (e.g. you or your company), the easiest way to share data between two apps on the same device is to set up an App Group that includes both your apps. Among other things, doing so will provide access to a shared directory both apps can access. You can then configure Realm to place its on-disk Realm file within the shared directory.
It is important to note, though, that the apps must always be using the same version of Realm, and they must always share the same schema and schema version. Unless you never change your schema or you can somehow ensure both apps are always updated at the same time, this might make sharing a Realm impractical. This limitation is known, and there are plans to address it.
This blog post discusses setting up an App Group and accessing the shared folder using NSFileManager
. Here is Apple's documentation on App Groups.
Upvotes: 2