【问题标题】:How to access xamarin Android environment.personal system folder?如何访问 xamarin Android environment.personal 系统文件夹?
【发布时间】:2017-08-21 10:14:54
【问题描述】:

我只是在使用 sqlite DB。我的数据库位置是 system.environmet.specialfolder.personal 那么如何访问这个文件夹

【问题讨论】:

标签: c# android xamarin.android


【解决方案1】:

以下是创建与位于System.Environment.SpecialFolder.Personal 的 SQLite 数据库的连接的方法:

public class SQLite_Android : ISQLite
{
    public SQLiteConnection GetConnection()
    {
        string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        var path = Path.Combine(documentsPath, "mySQLite.db"); // change mySQLite.db for your SQLite db filename
        // Create the connection
        var conn = new SQLiteConnection(path);
        // Return the database connection
        return conn;
    }
}

public interface ISQLite
{
    SQLiteConnection GetConnection();
}

【讨论】:

  • 感谢您的回答。但如果我想看看我的“mysqlite.db”文件在哪里。可以访问这个文件吗??
  • 由于移动应用程序在沙箱中运行,您只能从应用程序中访问您的 SQLite 数据库。如果您只想查看路径,则可以查看path 变量的内容。但是,例如,您不能使用文件浏览器访问数据库,或从其他应用程序访问数据库。
  • 您可能还会发现这个问题的答案很有用:stackoverflow.com/questions/26396105/…
猜你喜欢
  • 2011-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-24
  • 2020-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多