Description
I recently discovered that my database needed to be encrypted. I had everything working with sqlite-net-pcl (v1.5.231). Because of the need for an encrypted database. I removed sqlite-net-pcl and replaced with sqlite-net-sqlcipher. Then, I added the following code to key the database for encryption:
public SQLiteAsyncConnection GetConnection()
{
//var personalPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var personalPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
var path = Path.Combine(personalPath, "databases\TPS.db");
string password = "SecretPassword";
SQLiteAsyncConnection sqLiteAsyncConnection = new SQLiteAsyncConnection(path, storeDateTimeAsTicks: true, key: password);
sqLiteAsyncConnection.QueryAsync("PRAGMA key='?'", password);
return sqLiteAsyncConnection;
}
I pulled the db across and it appears to be encrypted. I was able to open the db in DB Browser for SQLite using the encryption password. So far so good.
However, my commands to the database using QueryAsync<> no longer retrieve records. There is no error that I can see in debugger or device monitor tool. There are just no records retrieved. However, using the Table<> command, I am able to retrieve the records. Is QueryAsync<> broken in sqlite-net-sqlcipher, or am I doing something wrong? See code sample below:
This works:
var manifests = await App.TPS_Database.DBConnection.Table<Manifest_T>().OrderBy(m => m.Name).ToListAsync();
But, this does not work, but it used to. For complicated queries, I needed this to work:
var manifests =
await App.TPS_Database.DBConnection.QueryAsync<Manifest_T>("select ID, Name from Manifest_T");