0

Currently my app wants to add a widget. I know that in order to use a database in a widget, I need to use the database in the path created using the app group. In this case, usually only widgets use a shared database? Or will the app database itself use a shared database as well?

If I use a shared database like this, this database becomes a new database without data. If the app db also uses a shared database, Should I migrate the database data? Is this the normal way? I don't know if I'm doing it right.

seonwoo
  • 11
  • 1
  • An app has its own sandbox area. Normally when you create a DB it is inside the sandbox. For a shared DB you can create app groups and then create the shared DB there. Your app will have access to the sandbox DB and the shared DB. Extensions will only have access to shared DB. – user1046037 Dec 12 '22 at 00:23
  • Since the extension has access only to the shared DB you could use History Tracking to copy relevant data to the shared DB. Normally your extension would only need a subset of the app data. If the extension is going to all your app data might as well use a shared db for your app as well. – user1046037 Dec 12 '22 at 00:25
  • @user1046037 Thank you for your reply. What you mean is that if I want the widget to use all the data of the app, the db used by the app should also use the shared db? – seonwoo Dec 13 '22 at 00:33
  • Yes, that is my view, if it is a small subset, then you could mirror the data, if all the data is needed by the extension it would make sense both app and extension to use the shared db. – user1046037 Dec 13 '22 at 04:33

0 Answers0