本文介绍了什么是“新闻"? Android中的SQLite数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andoid应用程序的数据库目录(/data/data/com.me.myApp/databases)中,对于我创建的每个sqlite数据库,都有一个对应的同名数据库,其名称后附加了"-journal".

In my andoid application's database directory (/data/data/com.me.myApp/databases), for every sqlite database I create there is a corresponding database of the same name with "-journal" appended to it's name.

例如:myDatabase,myDatabase-journal,myOtherDatabase.db,myOtherDatabase.db-journal

e.g: myDatabase, myDatabase-journal, myOtherDatabase.db, myOtherDatabase.db-journal

这是什么?

如果我正在为我的应用程序提供预填充的数据库(按照: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/)是否也需要包含这些内容? ?'

If I'm providing pre-filled databases for my app (as per: http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/) do I need to include these as well?'

推荐答案

不需要分发此类-journal文件(并且应分发 not ).

Such -journal files do not need to (and should not) be distributed.

这是因为各种日记文件表示临时数据(请参阅 SQLite的使用SQLite使用的临时磁盘文件).特别是-journal文件是回滚日志.

This is because the various journal files represent temporary data (ref. SQLite's Use Of Temporary Disk Files) used by SQLite. In particular a -journal file is a rollback journal.

回滚日志通常在首次启动事务时创建,并且通常在事务提交或回滚时被删除.回滚日志文件对于实现SQLite的原子提交和回滚功能至关重要.没有回滚日志,SQLite将无法回滚不完整的事务,并且如果在事务中间发生崩溃或断电,那么如果没有回滚日志,整个数据库可能会损坏.

The rollback journal is usually created when a transaction is first started and is usually deleted when a transaction commits or rolls back. The rollback journal file is essential for implementing the atomic commit and rollback capabilities of SQLite. Without a rollback journal, SQLite would be unable to rollback an incomplete transaction, and if a crash or power loss occurred in the middle of a transaction the entire database would likely go corrupt without a rollback journal.

通常,这些-journal文件仅在存在打开的SQLite数据库(或者更确切地说是正在运行的事务)时存在,但可以通过 PRAGMA journal_mode .使用默认的编译指示设置,-journal文件将被删除.

In general these -journal files should only exist when there is an open SQLite database - or rather, a running transaction - but can be controlled via PRAGMA journal_mode. With default pragma settings the -journal files will be deleted.

当未打开数据库并且所有的日志已被SQLite本身删除(或清除)时,请确保仅复制 实际的数据库文件;这意味着所有事务都已完成,并且数据库处于一致状态.

Make sure to only copy the actual database files when the database is not opened and all journals have been deleted (or cleared) by SQLite itself; this implies all transactions have been completed and the database is in a consistent state.

这篇关于什么是“新闻"? Android中的SQLite数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 17:12