SQLitePCL.raw icon indicating copy to clipboard operation
SQLitePCL.raw copied to clipboard

UWP: create database outside of app local data store

Open tedrog36 opened this issue 6 years ago • 11 comments

I'm hoping you might be able to help. I am using sqlite-net-pcl which in turn uses SQLitePCL.raw. I am trying to store my sqlite database in UWP outside of the app local data store. I want to store it in a location that the user has picked and that I have stored in the StorageApplicationPermissions.FutureAccessList.

My understanding from this article is that the low-level sqlite implementation uses CreateFile2 which fails outside of the app local data store. (the code project article was written for WP8 so not sure whether it is still valid)

Any ideas on how I could accomplish this?

tedrog36 avatar Sep 17 '18 12:09 tedrog36

Referencing aspnet/Microsoft.Data.Sqlite#287

I don't think I have any easy answers here. I don't have experience with using UWP in this way.

From the article, it kinda looks like people try to workaround UWP's rules here with a sqlite VFS. But I wonder how "official" that is. Would a UWP app fail store validation if it did this? But this is just me thinking out loud.

ericsink avatar Sep 18 '18 14:09 ericsink

I write files outside of the app local data store all the time so I don't think creating the database there would be an UWP validation issue. You have to let the user pick the folder and then add it to the FutureAccessList and then both standard .NET file I/O or StorageFolder/StorageFile stuff works fine. Does your library provide access to the methods to wire in a new VFS? I tried putting one together using the code project article as a guide but my UWP C++ and C# interop skills are lacking!

tedrog36 avatar Sep 18 '18 15:09 tedrog36

No, SQLitePCL.raw does not expose APIs to allow a VFS to be written in C#.

ericsink avatar Sep 18 '18 15:09 ericsink

@ericsink since I am using sqlite-net-pcl and SQLitePCL.raw, any ideas how I would wire in a new VFS if I ever figure out how to build one?

tedrog36 avatar Sep 28 '18 12:09 tedrog36

This is pretty much the last straw for me in using UWP. MS doesn't seem to care that you get to a certain point in development and then there's simply no way to accomplish what you're trying to do because of an overly-aggressive sandbox.

jefffhaynes avatar Jan 11 '19 21:01 jefffhaynes

overly-aggressive sandbox

Empathetic 👍. UWP has been death by a thousand paper cuts since its inception in Windows 8. Who blocks connections to localhost, and who requires a dialog box to interact with the local file system!

bricelam avatar Jan 14 '19 18:01 bricelam

It’s a shame because UWP is almost a really good framework but seems to suffer from neglect, lack of follow-through, and paranoia :)

jefffhaynes avatar Jan 14 '19 18:01 jefffhaynes

And out of that neglect, Uno was born.

bricelam avatar Jan 14 '19 18:01 bricelam

Interesting. Thanks!

jefffhaynes avatar Jan 14 '19 19:01 jefffhaynes

For all that's great about UWP and there is a lot, it's just one aggravation after another. Opening a SQLite database from somewhere other than isolated storage as a prime example. "Well, you can copy the database into isolated storage, then copy it back out when you're done.".

Without some change UWP will continue to flounder because people who want to get apps out on time with the functionality requested will choose other platforms.

blakepell avatar May 31 '19 20:05 blakepell

Is it possible to use API Redirection to solve this issue? There is an example for c++, but I couldn’t figure out how to use this with EntityFrameworkCore. I am new to С# and have little understanding of how the call chain goes. Perhaps you have ideas on how to use this.

vessd avatar Dec 27 '19 19:12 vessd

Closing old/stale issue.

ericsink avatar Sep 22 '22 21:09 ericsink