# net.sqlcipher.database.SQLiteException

**URL:** <https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587>\
**Category:** SQLCipher\
**Created:** [January 12, 2018, 10:04am UTC](https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587 "2018-01-12T10:04:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![payas\_gupta](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@payas\_gupta](https://discuss.zetetic.net/u/payas_gupta)\
**Post date:** [January 12, 2018, 10:04am UTC](https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587/1 "2018-01-12T10:04:47Z")

</div>

I’m using SQLCipher for android Implementation-Version: v3.5.4-5-g87be8c4  
I’m getting below crash reports from play store of customers but stacktrace doesn’t give much information.  
net.sqlcipher.database.SQLiteException:  
at net.sqlcipher.database.SQLiteCompiledSql.native\_compile (SQLiteCompiledSql.java)  
at net.sqlcipher.database.SQLiteCompiledSql.compile (SQLiteCompiledSql.java:91)  
at net.sqlcipher.database.SQLiteCompiledSql. (SQLiteCompiledSql.java:64)  
at net.sqlcipher.database.SQLiteProgram. (SQLiteProgram.java:83)  
at net.sqlcipher.database.SQLiteQuery. (SQLiteQuery.java:49)  
at net.sqlcipher.database.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:42)  
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1785)  
at net.sqlcipher.database.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1750)  
at net.sqlcipher.database.SQLiteDatabase.keyDatabase (SQLiteDatabase.java:2404)  
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal (SQLiteDatabase.java:2333)  
at net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1114)  
at net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1006)  
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase (SQLiteOpenHelper.java:249)  
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase (SQLiteOpenHelper.java:214)

Generally there is message logged like “file is encrypted or not a database” which could lead opening db with wrong key.  
I’m looking for what are possible scenarios when actual message is not logged in stacktrace ?

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [January 12, 2018, 2:15pm UTC](https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587/2 "2018-01-12T14:15:54Z")

</div>

Hi @payas_gupta

> [@payas\_gupta](#):
>
> Generally there is message logged like “file is encrypted or not a database” which could lead opening db with wrong key.
> 
> I’m looking for what are possible scenarios when actual message is not logged in stacktrace ?

It would depend on how your application handles exceptions. SQLCipher for Android will always throw an exception when you attempt to open the database with an invalid password. As an aside, you might consider updating your library, we’ve had several improvements to the library since 3.5.4, which is currently 3.5.9.

---

<div class="post-metadata">

**Author:** ![payas\_gupta](https://avatars.discourse-cdn.com/v4/letter/p/46a35a/32.png) [@payas\_gupta](https://discuss.zetetic.net/u/payas_gupta)\
**Post date:** [January 14, 2018, 1:23pm UTC](https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587/3 "2018-01-14T13:23:36Z")

</div>

Thanks for the reply, I will update libraries. My application doesn’t suppresses exception message and it logs every stacktrace possible. As you can see from above log snippet exception came in sqlcipher library for which actual cause is not present. I’m just curious what could be possible scenario where actual message is not logged.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [January 15, 2018, 3:15pm UTC](https://discuss.zetetic.net/t/net-sqlcipher-database-sqliteexception/2587/4 "2018-01-15T15:15:08Z")

</div>

Hi @payas_gupta

> [@payas\_gupta](#):
>
> exception came in sqlcipher library for which actual cause is not present.

Unfortunately, there are many possible reasons that SQLCipher may not be able to open a file. Providing an invalid password is the most typical scenario, however other issues could arise in which SQLCipher is not able to determine the root cause. For example, if you provide the path to a corrupt database, SQLCipher may not be able to open it.

> [@payas\_gupta](#):
>
> I’m looking for what are possible scenarios when actual message is not logged in stacktrace ?

Not being able to access the database should always cause an exception to occur. Within the SQLCipher for Android [test suite](https://github.com/sqlcipher/sqlcipher-android-tests) we have tests around [invalid open arguments](https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/app/src/main/java/net/zetetic/tests/InvalidOpenArgumentTest.java) and [invalid passwords](https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/app/src/main/java/net/zetetic/tests/InvalidPasswordTest.java) as an example.
