gpt4 book ai didi

sqlite - Xamarin Android - 在哪里存储本地数据库以便我可以查看它

转载 作者:行者123 更新时间:2023-12-02 07:51:49 25 4
gpt4 key购买 nike

我目前正在使用此代码将本地 sqlite 数据库保存在 Environment.GetFolderPath(Environment.SpecialFolder.Personal) 中。

现在我正在尝试将数据库复制到我的电脑上,以便我可以查看其中的内容。但除非它已root,否则我无法看到该文件夹​​。

哪里是保存数据库的最佳位置,以便我可以时不时地查看它?

这是我的 android DB 代码:

[assembly: Dependency(typeof(SQLite_Android))]

namespace AppName.Droid
{
public class SQLite_Android : ILocalDb.Interfaces.ILocalDb
{
#region ISQLite implementation
public SQLite.SQLiteConnection GetConnection()
{
var sqliteFilename = "MyDb.db3";
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, sqliteFilename);
// Create the connection
var conn = new SQLite.SQLiteConnection(path);
// Return the database connection
return conn;
}
#endregion
}
}

最佳答案

您可以使用外部存储选项:

        var sqliteFilename = "MyDb.db3";
var extStoragePath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
var path = Path.Combine(extStoragePath, "MyNewFolder");
var filename = Path.Combine(path, sqliteFilename);

// Create the connection
var conn = new SQLite.SQLiteConnection(path);
// Return the database connection
return conn;

这样文件将通过文件资源管理器可见

关于sqlite - Xamarin Android - 在哪里存储本地数据库以便我可以查看它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40236946/

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