The program gets a cursor and loops through it with while(cursor.moveToNext())
in several different places but one in particular is constantly giving this exception:
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): Caused by: android.database.sqlite.SQLiteDiskIOException: disk I/O error
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.sqlite.SQLiteQuery.native_fill_window(Native Method)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:75)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:296)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:269)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:171)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at android.database.AbstractCursor.moveToNext(AbstractCursor.java:256)
01-08 09:00:06.168: ERROR/AndroidRuntime(13434): at ... [my code]
Watching it in the de开发者_运维知识库bug, it gets to the while(cursor.moveToNext())
line and then pauses for a couple seconds before throwing this error.
What are possible issues that would throw this error?
Additional info
If I try to call cursor.getCount()
it also crashes with the same exception.
The issue was only affecting one table in the database. I took the database file off the phone and opened it on my computer and it seemed fine. I was able to run the same query on it that was causing the problem and it worked just fine.
I then completely removed the app from the phone and reinstalled it fresh and the problem seems to have gone away. So on one hand it looked like a corrupted table and on the other it didn't...
Update
This error is happening again to the same table. After reinstalling the app on the device the problem went away for a while. I'll see if I can track down when it starts.
I found out this was happening when the tables involved in the query got to be a certain size. It was doing a fairly expensive JOIN and it seemed like it was too intensive.
I saw this same exception in my android EMULATOR:
Indeed, I had executed a SQL query with a couple of joins, which returned a good bunch of results. When I ran this same query with another test User, with less data, I did not saw the exception.
However, when testing this same situation in my Samsung Galaxy Tab, thankfully, it worked fine :P.
I suppose it's the memory limits of the EMULATOR?
I was getting this error with an union query on two tables. As it's not possible to apply directly a limit on union with sqlite, the solution was to use subqueries as describe here
精彩评论