如题,头大,我用一些工程机测试时数据库坏掉的时候会本身删掉本身。。。。。。。。尤为是旧的(android4.0)出现频率还挺高的。修都没的修。html
SQLite有一个很严重的缺点就是不提供Repair命令。
致使死亡提示database disk image is malformed
它的产生有不少种可能,好比,磁盘空间不足,还有就是写入数据过程当中忽然掉电等。
官方对产生缘由的一些说明: http://www.sqlite.org/lockingv3.html#how_to_corruptjava
多线程操做也容易出现这种状况。android
估计我那边是由于多线程操做引发的。git
微信数据库用的是sqllite数据库,数据库的名称是EnMicroMsg.dbgithub
网上说密码用手机的IMEI+UIN,而后取md5加密后的前几位数字为密码,而后就能够看数据库的内容了。sql
微信把数据库框架WCDB也开源了,https://github.com/Tencent/wcdb 地址在这里数据库
参考文档:https://github.com/Tencent/wcdb/wikiwindows
有空要看看他们的框架。他们主要为了就是下降数据库损坏率。微信
另外,我也问了朋友,他们项目用的realm,数据量大的时候查找很是快,可是坑很是多,其中一个坑就是查出来的对象不能用intent传递,只能传id。估计我这个项目先不换这个吧,毕竟查找少一些。数据条数很少。下个项目能够试试。多线程
---------------------2018/3/8 补充------------------
通过新一轮线上错误收集,发现天天都会有几回下面这个错误
android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1034)
java.sql.SQLException: Unable to run deleteById stmt on id 9295: DELETE FROM `inspect2_result` WHERE `generatedId` = ? com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:25) com.j256.ormlite.stmt.mapped.MappedDelete.deleteById(MappedDelete.java:75) com.j256.ormlite.stmt.StatementExecutor.deleteById(StatementExecutor.java:542) com.j256.ormlite.dao.BaseDaoImpl.deleteById(BaseDaoImpl.java:487) com.iots.epo.inspect.dao.sys.PendingRequestDao.deleteByGeneratedId(PendingRequestDao.java:124) com.iots.epo.inspect.service.HttpService$HttpRunnable.run(HttpService.java:439) java.lang.Thread.run(Thread.java:818)\nCaused by: java.sql.SQLException: updating database failed: DELETE FROM `inspect2_result` WHERE `generatedId` = ? com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:27) com.j256.ormlite.android.AndroidDatabaseConnection.update(AndroidDatabaseConnection.java:313 com.j256.ormlite.android.AndroidDatabaseConnection.delete(AndroidDatabaseConnection.java:194) com.j256.ormlite.stmt.mapped.MappedDelete.deleteById(MappedDelete.java:64) ... 5 more\nCaused by: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1034) android.database.sqlite.SQLiteConnection.nativeExecute(Native Method android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:555 android.database.sqlite.SQLiteSession.execute(SQLiteSession.java:619) android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:44) com.j256.ormlite.android.AndroidDatabaseConnection.update(AndroidDatabaseConnection.java:311) ... 7 more\n
在https://sqlite.org/rescode.html#ioerr_fstat 这里查错误代码,
The SQLITE_IOERR_FSYNC error code is an extended error code for SQLITE_IOERR indicating an I/O error in the VFS layer while trying to flush previously written content out of OS and/or disk-control buffers and into persistent storage. In other words, this code indicates a problem with the fsync() system call in unix or the FlushFileBuffers() system call in windows.
仍是很困惑