“SQLiteDiskIOException:错误代码 10:磁盘 I/O 错误”在 ICS 和 Samsung Nexus 上重新调整 DROP TABLE
我收到以下错误:
android.database.sqlite.SQLiteDiskIOException: error code 10: disk I/O error
at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:92)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1926)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1866)
我仅在 Samsung Nexus 手机上的 ICS 4.0.1 上收到此错误。在模拟器(Motorola Xoom 3.2 和 HTC Desire 2.3.3)上,代码运行良好。我的代码针对的是 SDK 版本 8 或 2.2.x。 execSQL
的执行方式如下:
db.execSQL("DROP TABLE IF EXISTS " + table.getTableName());
数据库存储在内部,而不是存储在 SD 卡上。关于如何解决这个问题有什么建议吗?
I'm getting the following error:
android.database.sqlite.SQLiteDiskIOException: error code 10: disk I/O error
at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:92)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1926)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1866)
I only get this error on ICS 4.0.1 on a Samsung Nexus phone. On an emulator, a Motorola Xoom 3.2 and an HTC Desire 2.3.3, the code works fine. My code is targeted at version 8, or 2.2.x, of the SDK. The execSQL
is executed as follows:
db.execSQL("DROP TABLE IF EXISTS " + table.getTableName());
The database is stored internally and not on an SD card. Any suggestions on how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了这个问题。
问题是,在 drop table 语句之前有一个 Context.deleteDatabase('dbName') 语句,该语句显然已删除了数据库,然后报告的 I/O 错误就很有意义了。
似乎之前已经使用了腰带和支架的方法(不必要)。
然而有趣的是,直到迁移到 ICS 后,这才显现为问题。
Solved this.
Problem was that prior to the drop table statements there was a
Context.deleteDatabase('dbName')
statement which had obviously removed the db, and the I/O error being reported then makes perfect sense.It seems that a belt and braces approach had been used previously (unnecessarily).
However the interesting thing is that this didn't manifest as a problem until the move to ICS.
当加密数据库无法使用外键/索引正确删除表时,我遇到了同样的问题。在删除表之前删除现有记录解决了问题:
I run into the same problem, when encrypted database was not able to properly drop table with ForeignKey/Index. Deleting existing records just before dropping table resolved issue: