SQLiteDiskIOException: se produce un error de E / S del disco en Cursor.moveToNext ()

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 debug, 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?

Información adicional

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...

Noticias

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.

preguntado el 08 de enero de 11 a las 17:01

It seems to be limited to a single table and I ran some tests to make sure it wasn't a concurrency issue so that may be the case. I'm going to see if I can get the database file off the disk and take a look at it. -

I pulled the db file off the disk and using a sqlite program I am able to open it and run the exact same query I am running in the app with no problem. -

3 Respuestas

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.

Respondido el 17 de enero de 11 a las 20:01

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?

Respondido 12 Abr '12, 23:04

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

contestado el 23 de mayo de 17 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.