Windows RT与SQLite文件权限问题 [英] Windows RT with SQLite file permissions question

查看:100
本文介绍了Windows RT与SQLite文件权限问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定Windows RT开发问题是否应该转到开发通用Windows应用程序表单,但它看起来像
Windows和Windows Phone下的唯一开发论坛应用类别它可以去哪里。  

Not sure if Windows RT development questions should go to the Developing Universal Windows Apps form but it looks like the only development forum under the Windows and Windows Phone App category where it could go.  

我正在用C#编写Windows RT应用程序。 其中一个要求是将数据存储在SQLite数据库中。 我非常熟悉使用SQLite for Windows Runtime的SQLite数据库,但其中一个要求是在多个用户可以访问的位置创建
数据库。 例如,我们将数据库放在c:\ aaa \ mydb \ db.sqlite中,然后当USER1,USER2或USER3登录到平板电脑并运行应用程序时,他们都将访问同一个数据库。

I am writing a Windows RT app with C#.  One of the requirements is to store the data in an SQLite database.  I am pretty familiar with using the SQLite databases using SQLite for Windows Runtime however one of the requirements is to create the database in a location that multiple users can access.  For example, we would put the database at c:\aaa\mydb\db.sqlite and then when USER1, USER2 or USER3 logs into the tablet and runs the application they would all access the same database.

我确实理解,使用SQLite,我们永远不会永远不会有数据库可用于我们应用程序的多个实例/用户,因为数据库将会损坏,我提出了这些问题,但要求仍然是那么我
必须尝试实现它并提出文件锁,因此多个用户无法同时访问该文件。

I do understand that, with SQLite, we should never never never have a database available to multiple instances/users of our application because the database will get corrupt and I have brought up those concerns however the requirement is still there so I have to attempt to implement it and come up with file locks so multiple users can not access the file at the same time.

我可以使用FolderPicker或FilePicker让用户指定数据库文件的位置。 然后,我可以将StorageAccessPermissions.FutureAccessList.Add()与StorageFile或StorageFolder一起使用,以便在应用程序运行时为文件/文件夹
授予读/写权限。 我的问题是,SQLite使用较低的杠杆API而不是Windows RT API来访问文件,因此似乎忽略了使用StoreageAccessPermisssions API设置的权限,并且SQLite无法使用
来创建或访问数据库文件。

I can use the FolderPicker or FilePicker to let the user specify the location of the database file.  I can then use StorageAccessPermissions.FutureAccessList.Add() with the StorageFile or StorageFolder to grant read/write permission to the file/folder whenever the application runs.  My problem is, SQLite uses a lower lever API and not the Windows RT API to access the files therefore it appears that the permissions that were set with the StoreageAccessPermisssions API is ignored and SQLite is unable to create or access the database file.

无论如何,我是否可以创建/访问SQLite可以在公共位置访问的数据库文件?

Is there anyway that I can create/access a database file that SQLite can access in a common location as described?

谢谢

推荐答案

对于您在Windows RT上提出的要求,没有好的解决方案。您的分析是正确的:SQLite需要直接访问其数据库文件,并且没有允许直接访问的可共享位置。所有共享文件夹都需要代理访问,SQLite
不使用。如果您不需要本地系统上的数据库,则可以将其放在服务器上并通过REST API访问它。如果应用程序是侧面加载的,您可以在Windows上本地执行相同的操作并启用循环,但这不适用于Windows RT。可能的
hack是将数据库从共享位置复制到ApplicationData以便在应用程序完成后将其复制回共享位置。由于你不会有两个用户同时使用它,这只需要在app
暂停或恢复时交换(我可能会将激活更改交换为更安全)
There is no good solution for what you ask on Windows RT. Your analysis is correct: SQLite requires direct access to its database file, and there are no shareable locations which allow direct access. All shared folders require brokered access, which SQLite doesn't use. If you don't need the database on the local system you could put it on a server and access it via a REST API. If the app is side loaded you could do the same thing locally on Windows and enable loop back, but that won't work on Windows RT. A possible hack would be to copy the database from the shared location to ApplicationData to use then copy it back out to the shared location when the app is done with it. Since you won't have two users using it simultaneously this only needs to be swapped when the app suspends or resumes (I'd probably swap on activation change to be a bit safer)


这篇关于Windows RT与SQLite文件权限问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆