Developing xamarin forms application with commercial license for each platform. I have included all the packages to the respective platforms.
We are creating DB(say test.db) with already populated tables(nearly 100 tables) using sqlite browser.
In each platform we are keeping test.db in respective custom folder.
On runtime we will copy test.db to device specific folder and we will rename it to say abc.db(our requirement).
From Xamarin PCL project we will establish DB connection and trying to execute Insert command and it throws the exception
“{SQLite.SQLiteException: file is not a database at SQLite.SQLite3.Prepare2 (SQLitePCL.sqlite3 db, System.String query)”
Below is code snippet…
public SQLiteHelperService(string filename, string license, string key)
{
try
{
Filename = filename;
_connection = new SQLiteConnection(filename, true, key);
_connection.ExecuteScalar<int>(String.Format("PRAGMA cipher_license = '{0}'", license));
CipherVersion = _connection.ExecuteScalar<string>("PRAGMA cipher_version;");
CipherFipsStatus = _connection.ExecuteScalar<string>("PRAGMA cipher_fips_status;");
}
catch (SQLiteException ex)
{
throw ex;
}
}
public bool Add(string query)
{
try
{
_connection.BeginTransaction();
_connection.Execute(query);
_connection.Commit();
return true;
}
catch (Exception ex)
{
_connection.Rollback();
}
return false;
}
If I comment out cipher related code and it will works fine.