我正在尝试将本地 SQLite 数据库存储在设备的内部存储器中。当我使用模拟器时,这是:
static string dbName = "totems.sqlite";
string dbPath = Path.Combine (Android.OS.Environment.ExternalStorageDirectory.ToString (), dbName);
工作正常。但是当我尝试在我的 Nexus 5 上调试时,它没有用,因为它没有外部存储。我搜索了它的存储位置,以便它也可以在我的 Nexus 上运行。我将其替换为:
static string dbName = "totems.sqlite";
string dbPath = Path.Combine ("/data/data/com.companyname.totem/databases/", dbName);
但现在它无法在我的 Nexus 5 上运行,也无法在我的模拟器上运行。它说找不到路径。
我做错了什么?
提前致谢。
最佳答案
我知道这是一个旧线程,但旧答案有错字。工作语法应该是:
string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "DatabaseName.txt");
关于c# - 在 Xamarin Android 中存储 SQLite 数据库的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33900112/