SQLite VACUUM命令 [英] SQLite VACUUM Command
问题描述
通常我正在使用我的应用程序,下载超过30000没问题.但我看到 android开发者控制台(崩溃和ANRS)中开始出现此错误.
Well normally I am using my application and there is no problem over 30000 download. but I see that This error begin to come in android developer console (Crash & ANRS).
按应用版本 3.1.1 1 100.0%
by app version 3.1.1 1 100.0%
通过Android版本Android 2.3.3-2.3.7 1 100.0%
by Android version Android 2.3.3 - 2.3.7 1 100.0%
通过设备刀片(刀片)
这是我的代码:
public void deletetable(String Tablename){
SQLiteDatabase db = mContext.openOrCreateDatabase(DB_NAME,
Context.MODE_PRIVATE, null);
db.delete(Tablename, null, null);
db.execSQL("VACUUM");
}
这是报告:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)
Caused by: android.database.sqlite.SQLiteDiskIOException: disk I/O error: VACUUM
at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1763)
at com.restroomgames.kpss.TestAdapter.deletetable(TestAdapter.java:194)
at com.restroomgames.kpss.TrGenelSinavAnasayfa.yenile(TrGenelSinavAnasayfa.java:395)
at com.restroomgames.kpss.TrGenelSinavAnasayfa$refreshyazi.doInBackground(TrGenelSinavAnasayfa.java:381)
at com.restroomgames.kpss.TrGenelSinavAnasayfa$refreshyazi.doInBackground(TrGenelSinavAnasayfa.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
... 4 more
推荐答案
来自VACUUM文档:
From VACUUM Documentation:
VACUUM命令通过将数据库内容复制到 临时数据库文件,然后使用 临时文件的内容.覆盖原件时, 回滚日志或预写日志WAL文件的使用方式与以前一样 用于任何其他数据库事务. 这意味着在抽真空时 一个数据库,其大小是原始数据库文件的两倍 所需的可用磁盘空间.
磁盘上可能没有足够的可用空间来执行VACUUM操作.
http://sqlite.org/lang_vacuum.html
The VACUUM command works by copying the contents of the database into a temporary database file and then overwriting the original with the contents of the temporary file. When overwriting the original, a rollback journal or write-ahead log WAL file is used just as it would be for any other database transaction. This means that when VACUUMing a database, as much as twice the size of the original database file is required in free disk space.
It may be that there is not enough free space available on disk to perform the VACUUM operation.
http://sqlite.org/lang_vacuum.html
这篇关于SQLite VACUUM命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!