我有一个由 Android 上的 .Net 7 Maui 应用程序创建的数据库文件:
public static class Constants
{
public const SQLite.SQLiteOpenFlags OpenFlags =
// open the database in read/write mode
SQLite.SQLiteOpenFlags.ReadWrite |
// create the database if it doesn't exist
SQLite.SQLiteOpenFlags.Create |
// enable multi-threaded database access
SQLite.SQLiteOpenFlags.SharedCache;
public const SQLite.CreateFlags CreateFlags =
SQLite.CreateFlags.None;
}
static public SQLiteAsyncConnection Database;
Database = new SQLiteAsyncConnection("some path", Constants.OpenFlags);
数据库存储我的应用程序使用的一些数据。
我需要数据库文件中的数据只能由我的应用程序读取。
有谁知道如何使其只能由我的应用程序读取?
谢谢。
您可以加密您的数据库
using SQLite;
var options = new SQLiteConnectionString(_databasePath, true, "password", postKeyAction: c =>
{
c.Execute("PRAGMA cipher_compatibility = 3");
});
_database = new SQLiteAsyncConnection(options);
await _database.CreateTableAsync<Obj>();