现在的位置: 首页 > 综合 > 正文

Android 短信数据库与联系人数据下的.db-wal文件

2012年01月16日 ⁄ 综合 ⁄ 共 972字 ⁄ 字号 评论关闭

Android 2.3开始采用Sqlite 3.7,而SQLite 3.7开始引入WAL Mode(Write Ahead Log),一种新的事务控制机制,

所以我们会在系统的短信与联系人的数据库下看到.db-wal的文件格式,如图所示。

引入的目的是为了保证数据库中的一致性,避免程序发生崩溃的时候也能保证数据库的一致性。所以,这就是为什么

第3方的程序有时能够正常读到联系人的数据,有时却读不到的原因,用户遇到这种情况,最好重启下机器。

WAL文件格式的详细说明见: http://www.sqlite.org/fileformat2.html

其中提到:

A WAL file consists of a header followed by zero or more "frames". Each frame records the revised content of a single page from the database file. All changes to the database are recorded by writing frames into the WAL. Transactions commit when a frame is written that contains a commit marker. A single WAL can and usually does record multiple transactions. Periodically, the content of the WAL is transferred back into the database file in an operation called a "checkpoint".

A single WAL file can be reused multiple times. In other words, the WAL can fill up with frames and then be checkpointed and then new frames can overwrite the old ones. A WAL always grows from beginning toward the end. Checksums and counters attached to each frame are used to determine which frames within the WAL are valid and which are leftovers from prior checkpoints.

【上篇】
【下篇】

抱歉!评论已关闭.