gpt4 book ai didi

sqlite - 如何在Xamarin表单中使用SqLite?

转载 作者:行者123 更新时间:2023-12-03 18:43:54 24 4
gpt4 key购买 nike

大家。
我在Xamarin表单中使用SqLite。为此,我正在使用SqLite-PCL nuget。现在的问题是,它在Android中工作正常。但是在UWP中,我无法访问数据库文件。
我在两个平台上都使用通用代码。如下:

database = new SQLiteConnection(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "mydb.db"));
database.CreateTable<Item>();

我仅在UWP应用中得到的错误。
Error Screen Shot
谢谢。

最佳答案

docs包含有关如何在UWP中执行此操作的明确说明

using Windows.Storage;
...

[assembly: Dependency(typeof(FileHelper))]
namespace Todo.UWP
{
public class FileHelper : IFileHelper
{
public string GetLocalFilePath(string filename)
{
return Path.Combine(ApplicationData.Current.LocalFolder.Path, filename);
}
}
}

关于sqlite - 如何在Xamarin表单中使用SqLite?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49027928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com