How can I use ORMLite with SQLCipher together in Android?

前端 未结 5 2176
轻奢々
轻奢々 2020-12-05 15:12

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 a

5条回答
  •  萌比男神i
    2020-12-05 15:33

    How can I use ORMLite with SQLCipher together in Android?

    It should be possible @Bruno.

    One way that should work is to just copy ORMLite's OrmLiteSqliteOpenHelper class into your project, rename it to LocalOrmLiteSqliteOpenHelper or something, and change the base class to be the SQLCipher helper class. I can't believe they didn't rename the class to be SQLCipherSQLiteOpenHelper. (grumble)

    public abstract class LocalOrmLiteSqliteOpenHelper
        extends info.guardianproject.database.sqlcipher.SQLiteOpenHelper {
    

    Another way would be to have your helper extend SQLCipher's SQLiteOpenHelper and then implement the various things you need from OrmLiteSqliteOpenHelper yourself. That would take a bit more work however. ORMLite has to do a little dance with database connections while the database is being created otherwise it goes recursive.

    Let me know if either of these work.

提交回复
热议问题