wcdb
wcdb copied to clipboard
Fatal Exception: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
The language of WCDB
e.g. Java
The version of WCDB
e.g. v1.0.8
The platform of WCDB
e.g. Android
The installation of WCDB
e.g. Maven
What's the issue?
SQLiteCipherSpec cipherSpec = new SQLiteCipherSpec() // 指定加密方式,使用默认加密可以省略 .setPageSize(4096) .setKDFIteration(64000);
WCDBOpenHelperFactory factory = new WCDBOpenHelperFactory() .passphrase("passphrase".getBytes()) // 指定加密DB密钥,非加密DB去掉此行 .cipherSpec(cipherSpec) // 指定加密方式,使用默认加密可以省略 .writeAheadLoggingEnabled(true) // 打开WAL以及读写并发,可以省略让Room决定是否要打开 .asyncCheckpointEnabled(true); // 打开异步Checkpoint优化,不需要可以省略
AppDatabase db = Room.databaseBuilder(this, AppDatabase.class, "app-db") //.allowMainThreadQueries() // 允许主线程执行DB操作,一般不推荐 .openHelperFactory(factory) // 重要:使用WCDB打开Room .build();
When I addMigration to add a new Tablesuch as
AppDatabase db = Room.databaseBuilder(this, AppDatabase.class, "app-db") .addMigration(XXX) .openHelperFactory(factory) // 重要:使用WCDB打开Room .build();
The problem occurs :
Fatal Exception: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
When I remove .openHelperFactory(factory) , There is nothing wrong
So I think my SQL to add a new Table is OK
@mikelhm 你好,请问你现在解决这个问题了么?我这边也会报这个异常
Please try v2.1.0.