greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

When using an encrypted database, onDowngrade is not supported, and the database will crash when it is downgraded #1043

Open zhaolifan opened 4 years ago

zhaolifan commented 4 years ago

使用加密数据库时,通过getEncryptedWritableDb获取EncryptedHelper,EncryptedHelper不支持onDowngrade,数据库降级时会崩溃

When using an encrypted database, get the EncryptedHelper through getEncryptedWritableDb. EncryptedHelper does not support onDowngrade, and the database will crash when it is downgraded

greenrobot-team commented 4 years ago

The greenDAO API is using a rather outdated version of the SQLite and SQLCipher APIs which did not support onDowngrade(), yet. A workaround is to write a custom open helper and manually call the relevant DaoMaster methods. Then pass whatever Database got created to DaoMaster(database).