# DB is not getting encrypted

**URL:** <https://discuss.zetetic.net/t/db-is-not-getting-encrypted/3686>\
**Category:** SQLCipher\
**Created:** [May 21, 2019, 5:54pm UTC](https://discuss.zetetic.net/t/db-is-not-getting-encrypted/3686 "2019-05-21T17:54:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shyam\_Sundar](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/shyam_sundar/32/1067_2.png) [@Shyam\_Sundar](https://discuss.zetetic.net/u/Shyam_Sundar)\
**Post date:** [May 21, 2019, 5:54pm UTC](https://discuss.zetetic.net/t/db-is-not-getting-encrypted/3686/1 "2019-05-21T17:54:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [May 21, 2019, 6:52pm UTC](https://discuss.zetetic.net/t/db-is-not-getting-encrypted/3686/2 "2019-05-21T18:52:17Z")

</div>

Hello @Shyam_Sundar - I noticed you also opened up a support ticket with us at [support@zetetic.net](mailto:support@zetetic.net). Since you are a Commercial Edition licensee with active CipherCare support we are responding to your inquiry privately there.

---

<div class="post-metadata">

**Author:** ![Shyam\_Sundar](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/shyam_sundar/32/1067_2.png) [@Shyam\_Sundar](https://discuss.zetetic.net/u/Shyam_Sundar)\
**Post date:** [May 22, 2019, 6:39am UTC](https://discuss.zetetic.net/t/db-is-not-getting-encrypted/3686/3 "2019-05-22T06:39:29Z")

</div>

Thanks for the clarification Stephen… going forward we will continue with the support ticket that I have raised.

Regards,

Shyam
