在 Android 手机上找到 Sqllite 数据库

问题描述 投票:0回答:1

请建议我在 Android 手机上哪里可以找到 MCQ.db3 Sqlite 数据库。

https://github.com/KalyanAllam/MauiAppMCQs

SQLiteAsyncConnection Database;
        private SQLiteAsyncConnection _dbConnection;
        public const string DatabaseFilename = "MCQ.db3";
        async Task Init()
        {  
        string dbPath  =
         Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
            _dbConnection = new SQLiteAsyncConnection(dbPath);
            if (Database is not null)
                return;
            Database = new SQLiteAsyncConnection(dbPath, Constants.Flags);
    
            var result = await Database.CreateTableAsync<InQuestion>();
        }
c# .net sqlite maui
1个回答
0
投票

将在 dbPath 的值处创建 MCQ.db3。它的价值是

/data/user/0/com.companyname.yourappname/files/MCQ.db3
。并且你也可以尝试debug来检查一下。

此外,仅使用

Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
不会创建文件。您需要自己创建该文件。如:

string dbPath  =
         Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
FileStream fileStream = 
         new FileStream(aaa, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

然后您将在/data/user/0/com.companyname.yourappname/files文件夹中找到

MCQ.db3

© www.soinside.com 2019 - 2024. All rights reserved.