Share local SQLite database in 2 different xamarin forms apps Share local SQLite database in 2 different xamarin forms apps sqlite sqlite

Share local SQLite database in 2 different xamarin forms apps


In the case of iOS, it's sandboxed so sharing data between applications are so difficult. But there are still some ways to share data between applications.

In your case, I recommend you using App Groups. An App Group allows different applications (or an application and its extensions) to access a shared file storage location, please refer to Working with App Groups for more details.

After Adding an App to an App Group we can use the methods below to share data between applications:

NSUserDefaults:

var userDefaults = new NSUserDefaults("<your group ID>", NSUserDefaultsType.SuiteName);userDefaults.SetString("user123", "userId");userDefaults.Synchronize();

NSFileManager:

NSUrl appGroupDirectoryPath = NSFileManager.DefaultManager.GetContainerUrl("<your group Id>");NSUrl dataBaseUrl = appGroupDirectoryPath.Append("dbName.db", false);//You can try to copy your dataBase file to this url.


Yes it is possible to share the data between two iPhone apps ...If anybody need more information on this please go through the below link which will explain how to achieve...

Using your App Group

App Groups are the scheme iOS uses to allow different apps to share data. If the apps have the right entitlements and proper provisioning, they can access a shared directory outside of their normal iOS sandbox. Sandboxing still applies except for a single exception.

This is probably almost automatic, but when you get into iOS app provisioning you can't assume anything. What's supposed to happen is that you just turn on the "app groups" entitlement in Xcode for the app and for any extensions..


Link for:-Sharing the app extension

@Land Lu - MSFT Thanks for the suggestion your answer led me to get it done.