I would like to use OrmLite with SQLCipher in my Android project, but both libraries have their own abstract SQLiteOpenHelper
class to implement. Java don't allow a class to extend two classes and if I implement separately, they will not communicate with each other.
How can I work with both together? How do I resolve the SQLiteOpenHelper
implementation problem?
I have distilled the answer by Rejinderi into a patch for ORMLite 4.43 and compiled it into a JAR file. To integrate it in your Android project, do the following:
libs/ormlite-android.jar
with ormlite-android-sqlcipher.jar
However, you should not trust me to provide an unmanipulated JAR file and follow the build instructions in the patch instead.
EDIT: With the patched library, the calls to getReadableDatabase()
, getWritableDatabase()
and the OrmLiteSqliteOpenHelper
constructor need to be passed the password as additional parameter. If you are using a DB helper, extend it appropriately to pass the password to OrmLiteSqliteOpenHelper.