Mono.Data.Sqlcipher migrate databases from SQLCipher to


We have purchased Mono SQLCipher library and have been using it in our project.

Currently we are trying to update SQLCipher to the latest version ( to support Android 6.0 Marshmallow.

However we are not able to migrate databases from SQLCipher to

SqliteConnection .open fails with below error,

10-23 11:54:20.101: E/AndroidRuntime(9364): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: Mono.Data.Sqlcipher.SqliteException: File opened that is not a database file
10-23 11:54:20.101: E/AndroidRuntime(9364): file is encrypted or is not a database

How can I get to the step of providing PRAGMA cipher_migrate (or atleast changing the key to be PRAGMA cipher_default_kdf_iter = 4000;)

I dont see SQLiteDatabase or SQLiteDatabaseHook implemented in Mono.Android library


Hello @kart1986

Can you post the block of code you are attempting to execute, along with identifying the line which causes the exception? Thanks!


SqliteConnection ceConn = new SqliteConnection(connectionStr);
ceConn.Open(); // getting the error at this line, not sure where to call PRAGMA cipher_migrate;

I dont see SQLiteDatabase or SQLiteDatabaseHook implemented in Mono.Android library

Not sure as to where to go from here.

With the older library ( we dont get the same error on the database.

Our project is compiled using API Level 19 (Xamarin.Android v4.4 Support)


Hello @kart1986

I believe you will need to adjust the values that you provide as the connection string to the SqliteConnection. I am not certain what values you are providing, however the following example will work in migrating a 2.x database to the 3.x version. Could you give this a try and let us know your results?

var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), databaseName);

var connection =  new SqliteConnection(String.Format("Data Source={0};Pooling=false;Synchronous=Full;Journal Mode=Default;", databasePath));

connection.Open ();

using (var command = connection.CreateCommand ()) 
    command.CommandText = "PRAGMA cipher_migrate;";
    command.ExecuteNonQuery ();
conn.Close ();


Works!!! thanks mate

Previously our connection string was just as below,

“Data Source=”" + database + “”"


Hello @kart1986

I’m glad to hear adjusting the connection string resolved the issue for you. Take care!