我正在使用GreenDAO库 从旧版本升级到新版本后,我面临SQL异常 例: 版本1.0:数据库未加密 版本2.0:数据库已加密 现有用户使用1.0升级到2.0 在调用之后我得到异常,在此之前我必须在升级时加密旧数据库。怎么做?
helper.getEncryptedWritableDb(password);
net.sqlcipher.database.SQLiteException: file is encrypted or is not a database: , while compiling: select count(*) from sqlite_master;
at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:84)
at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:49)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1820)
at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1785)
at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2439)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2368)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1149)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1041)
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:249)
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:214)
at org.greenrobot.greendao.database.DatabaseOpenHelper.getEncryptedWritableDb(DatabaseOpenHelper.java:134)
at org.broadsoft.iris.datamodel.db.DatabaseManager.openWritableDb(DatabaseManager.java:149)
at org.broadsoft.iris.datamodel.db.DatabaseManager.openReadableDb(DatabaseManager.java:129)
at org.broadsoft.iris.datamodel.db.DatabaseManager.getContactIdsInMessageHistory(DatabaseManager.java:461)
at org.broadsoft.iris.http.HttpManagerV2.lambda$fetchVCards$2(HttpManagerV2.java:573)
at org.broadsoft.iris.http.HttpManagerV2.access$lambda$2(HttpManagerV2.java)
at org.broadsoft.iris.http.HttpManagerV2$$Lambda$3.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
答案 0 :(得分:0)
没有&#34;升级&#34;从SQLite(未加密)到SQLCipher(加密)。这是一个如何做的概述: