数据库没有进行密码加密,而且是在表和db文件创建成功后。插入数据,到第四条数据或者更晚就会数据库崩溃。
06-03 17:17:49.127 1047-1047/com.oceanx.light E/SQLiteLog: (26) file is encrypted or is not a database
06-03 17:17:49.127 1047-1047/com.oceanx.light E/DefaultDatabaseErrorHandler: Corruption reported by sqlite on database: /data/data/com.oceanx.light/databases/freelight.db
06-03 17:17:49.127 1047-1047/com.oceanx.light E/DefaultDatabaseErrorHandler: deleting the database file: /data/data/com.oceanx.light/databases/freelight.db
06-03 17:17:49.522 1047-1104/com.oceanx.light E/ libEGL: cache file failed CRC check
不出意外的话应该是版本问题,也有可能是SQLiteConnection对象的参数不完整或者多加了密码字段。其实这个问题网上有很多,
如:SQLiteConnection ("Data Source =" + + it._path ", Version =" + + it._version ", Password =" + it._password)
这种也会出现这个错误。
一个一个试吧
DatabaseError: file is encrypted or is not a database
There are typically three situations in which this somewhat cryptic error message can be seen:
when trying to modify the datab......
答案就在这里:DatabaseError: file is encrypted or is not a database
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?
DatabaseError: file is encrypted or is not a database
There are typically three situations in which this somewhat cryptic error message can be seen:
when trying to modify the database file and the write permission is missing; fix the permissions
when accessing a SQLite 2.x database file with a SQLite 3.x library; see above for the upgrade instructions.
when accessing a database that has been created in or explicitly converted to WAL mode, using a version of SQLite older than 3.7.0 (i.e. with no WAL support); upgrade your bindings to use a recent SQLite
大概就是因为文件访问权限丢失,或者新旧版本不兼容导致的。
不知道为什么会出现这个错误,感觉还是数据库本身的问题,你看看出错后插入的数据有没有放进去。查了下,说是兼容性问题。也不知道为什么会出这个错。。。我再找找看
android 9.0的sqlite3默认开启了WAL(Write-Ahead-Logging)预写式日志,数据库的工作方式发生了变化。
android 9.0以下的版本 不会出现“File opened that is not a database file file is encrypted or is not a database”。
处理方法:手动关闭WAL,强制使用JOURNAL模式。
DatabaseHelper helper=DatabaseHelper.getInstance(context);
db=helper.getReadableDatabase();
db.disableWriteAheadLogging(); //禁用WAL模式