I have downloaded the sqlcipher trail package for Xamarin.Android from the Xamarin Component Store and I’m trying to connect to a sqlite database using mono.data.sqlcipher, but I just cannot connect to the database. The error message that I get is just “sqlcipher” when I try to open the connection.
The database that I’m using is created with help System.Data.Sqlite in a. NET application. The database is not protected by a password, and I can open it without any problem in my Xamarin.Android app using Mono.Data.Sqlite.
This is the code that I’m trying to get to work:
connectString = @"Data Source=/data/data/com.blaise.depandroid/files/RuntimeConfiguration.db;";
var conn = new Mono.Data.Sqlcipher.SqliteConnection(connectString);
conn.SetPassword("");
conn.Open(); //Fails with errormessage "sqlcipher"
When I use Mono.Data.Sqlite instead the connection is opened without a problem.
What device are you deploying the application to? Can you adjust your project Options within the Android Build → Advanced tab section, please make sure you only have armeabi, armeabi-v7a, and x86 selected as the supported ABI’s?
SQLCipher for Xamarin will work on Genymotion, which emulator are you using? Are you including other 3rd party libraries with your application you are testing?
I’m using the Google Nexus 7 Android 4.4.4 API 19 emulator.and I’m not using a third party library.
Maybe there is something wrong with my project references: I have referenced SQLite.Net, SQLite.Net.Platform.SQLCipher.XamarinAndroid and SQLite.Net.Platform.XamarinAndroid
.
I figured out what was wrong. I had added the references to my class library (where the connection with the database is created) only, and not to the main app project. After I added the references to my main project the problem was gone. If you don’t do this, you’ll get dllimport errors of several sqlcipher .so files, because the files cannot be found.