简体   繁体   中英

How to share a SQLite database between an extension and the container app

I want to share a SQLite database between an app extension and the container app. The database is copied from the main bundle (of the container app) to an App Group. The extension reads and writes from that copy of the database. The problem is that if the extension is opened before the container app there is no database to read from. What can I do?

You could put a flag in NSUserDefaults based on the app group that indicates that the app has been opened once. Then the extension can check for this "key" and if missing display an suitable message.

How exactly are you copying the database to an App Group?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM