Xamarin.Forms get file is not a database both android and iOS


I am using trial version on Xamarin.iOS and Xamarin.Android(4.0.1)

I want to decrypt my sqlite database in the app.

I have some code in my constructor:

database = new SQLiteConnection(path, true, key);

database.ExecuteScalar<int>("PRAGMA kdf_iter = 4000;");
database.ExecuteScalar<int>("PRAGMA cipher_default_kdf_iter = 4000;");

database.ExecuteScalar<int>(String.Format("PRAGMA cipher_license = '{0}'", license));
database.ExecuteScalar<int>(String.Format("PRAGMA key = '{0}'", key));

Then I want to do some query like this:

return database.Query<UserInfo>("Select * from UserInfo where Cell = ? and Password = ?", cell, password);

I will get the file is not a database error…


Hello @1115

You do not need to execute the PRAGMA key command, that is handled for you with the constructor of the SQLiteConnection. If you are accessing a database file that was created with a different major version of SQLCipher, you might consider using the compatibility mode if you are unable to upgrade the file format directly. You can review your options in detail here.


Thank you so much!!
It works!


Hi @1115

Great, we are happy to hear that worked for you!