问题描述
我想用 OrmLite ,提供的在我的Android项目,但两个库都有自己的抽象 SQLiteOpenHelper
类来实现。 Java的不允许一个类来扩展两个类,如果我单独实现,他们不会互相沟通。
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.
如何可以与我一起工作的?我该如何解决 SQLiteOpenHelper
的实施问题?
How can I work with both together? How do I resolve the SQLiteOpenHelper
implementation problem?
推荐答案
这应该是可能的@Bruno。
It should be possible @Bruno.
应该工作的方法之一是把刚才复制 ORMLite的 OrmLiteSqliteOpenHelper
类到您的项目,将其重命名为 LocalOrmLiteSqliteOpenHelper
什么的,并更改基类是 SQLCipher
辅助类。我不能相信他们没有命名类是 SQLCipherSQLiteOpenHelper
。 (叽)
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 {
另一种方法是让你的助手延长 SQLCipher
的SQLiteOpenHelper,然后实现从 OrmLiteSqliteOpenHelper $ C $所需要的各种东西C>自己。这将需要更多的工作但是。 ORMLite有做小舞与数据库连接,同时正在创建的数据库,否则它会递归的。
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.
这篇关于我如何使用ORMLite与SQLCipher一起在Android的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!