请建议我在 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>();
}
将在 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。