Can SQLite and SQLCipher be used simultaneously?

Hi,
I have an android app which uses a library which in turn uses SQLite to store the data.
Now I want to use SQLCipher to store some confidential info.

As per documentation https://www.zetetic.net/sqlcipher/design/ under packaging section, it says SQLCpiher modifies SQLite and underlying use the SQLite version only.

  1. Will I be able to use SQLite and SQLCipher simultaneously?
  2. If the library updates the SQLite version it’s using or I upgrade SQLCipher version will either be a breaking change?

Hi @srikanth1003

Will I be able to use SQLite and SQLCipher simultaneously?

It is not recommend that you attempt to link an application with both SQLite and SQLCipher together. If you do not receive linker errors, at runtime there could most certainly be issues due to the internals of SQLite. Because SQLCipher can operate on plaintext SQLite database files (simply do not provide a password), you can use one library to interface with both SQLCipher encrypted database files and plaintext SQLite database files using a single library.

If the library updates the SQLite version it’s using or I upgrade SQLCipher version will either be a breaking change?

Using the two libraries together in a single application is unadvised, we cannot say whether or not it will work, or what operation(s) may potentially cause a crash. It should be avoided if possible.

Adding a case for better explanation.
React native Asyncstorage uses SQLite to store key value pair.
Now I would like to add Sqlcipher to store some confidential info.

How would both behave in this case?

Hello @srikanth1003 - What @developernotes was saying is that you should only use one SQLite library version at a time. If you are using SQLCipher you should ensure that SQLCipher is the only library linked to your application. Once you do, it is perfectly fine to use SQLCipher to open standard SQLite databases - it is fully compatible and operates exactly like SQLite when a database is not encrypted. So, in your example, you would need to make sure that your React native Asyncstorage used SQLCipher as linked. If it includes a different version of SQLite itself, resulting in two libraries being linked with the application, then the behavior would best be considered “undefined”. Let us know if that makes sense and answers your question.