I am about to embark on the development of a line of business application using the Universal Windows Platform (Windows 10). One of the requirements of the application is the synchronisation of data from a server to a local SQLite database; this is required because the application needs to be usable where there is no network connectivity.
It is likely that multiple (windows domain) users will be accessing the application on the same device, sometimes simply by "swapping users", other times by logging off the first user and logging on as a new user.
I realise that UWP applications are installed at a user level, however I would like to be able to share the SQLite database between these users instead of forcing each user to download their own copy of the data.
Is this possible? I am struggling to find any reference to this kind of sharing within the <a href="https://msdn.microsoft.com/library/windows/apps/dn894631.aspx" rel="nofollow">Microsoft documentation</a> - but of course that documentation is new and far from complete!
I guess at the end of the day I am looking for access to a folder that is accessible by any user running that application on the same device, such as the "<em>x</em>:\Users\Public" folders that are available from the desktop, but without having to ask the user to provide access to that folder via any picker control - instead simply being able to "open" it.
In case anyone runs across this, this functionality is now available as described in this <a href="https://blogs.windows.com/buildingapps/2016/05/24/sharing-your-local-app-data/" rel="nofollow">blog post</a>:<blockquote>
We introduced a new storage location Windows 10, ApplicationData.SharedLocalFolder, that allows multiple users of one app to share local data. Obviously this feature is only interesting with devices that will be used by more than one person. For such scenarios, for example in educational uses, it may make sense to place any large downloads in Shared Local. The benefits will be two-fold: any user can access these files without the need to re-download them, also there will be storage space savings
Keep in mind that Shared Local is only available if the machine has the right group policy, otherwise when you call ApplicationData.Current.SharedLocalFolder you will get back a null result.
In order to enable Shared Local the machine administrator should enable the corresponding policy.
<a href="https://i.stack.imgur.com/aFZtr.png" rel="nofollow"><img alt="Group Policy Change" class="b-lazy" data-src="https://i.stack.imgur.com/aFZtr.png" data-original="https://i.stack.imgur.com/aFZtr.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>
Alternatively, the administrator could create a REG_DWORD value called AllowSharedLocalAppData with a value of 1 under HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\AppModel\StateManager
<a href="https://i.stack.imgur.com/dGkFu.png" rel="nofollow"><img alt="Registry Change" class="b-lazy" data-src="https://i.stack.imgur.com/dGkFu.png" data-original="https://i.stack.imgur.com/dGkFu.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>
Note that data store in ShareLocal will only be persisted as long as the app is installed on the device and won’t be backed up by the system.</blockquote> Answer2:
In Solution Explorer , Right click on <strong>Package.appxmanifest</strong> then click on ViewCode , end of this file in both projects add below code :
<Extensions> <Extension Category="windows.publisherCacheFolders"> <PublisherCacheFolders> <Folder Name="FolderName" /> </PublisherCacheFolders> </Extension> </Extensions>
After that in code you can access this folder with below line of code :
StorageFolder sharedDownloadsFolder = ApplicationData.Current.GetPublisherCacheFolder("FolderName");
It`s so important that the folder you will share between two these Apps depend on same publisher info at Certificate File <strong>[ProjectName]_TemporaryKey.pfx</strong> , if this Certificate File and publisher Info of app is same in both Projects , then you can access the same <strong>SharedFolder</strong> in both application and use it for create or use dataBase file(like SQLite Database file) or other files that need to be share in both applications.