开发者

Android android.database.CursorIndexOutOfBoundsException: Index 2 requested, with a size of 2

开发者 https://www.devze.com 2023-03-23 03:41 出处:网络
I have this log 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): FATAL EXCEPTION: main 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): android.database.CursorIndexOutOfBoundsException: Index 2 reque

I have this log

07-27 21:42:05.635: ERROR/AndroidRuntime(26094): FATAL EXCEPTION: main 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): android.database.CursorIndexOutOfBoundsException: Index 2 requested, with a size of 2 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at it.android.infoconsumatori.ServiceS$1.handleMessage(ServiceS.java:101) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.os.Handler.dispatchMessage(Handler.java:99) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.os.Looper.loop(Looper.java:123) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at android.app.ActivityThread.main(ActivityThread.java:3691) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at java.lang.reflect.Method.invoke(Method.java:507) 07-27 21:42:05.635: ERROR/AndroidRuntim开发者_StackOverflowe(26094): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 07-27 21:42:05.635: ERROR/AndroidRuntime(26094): at dalvik.system.NativeStart.main(Native Method) 07-27 21:42:05.640: ERROR/(2695): Dumpstate > /data/log/dumpstate_app_error

What is the problem ??


That means you are accessing an item that does not exist. Think of it like this: A cursor has a certain number of rows (the data you want to access), these rows are Zero-indexed, meaning that if there are 10 rows of data, the first row of data is Index 0, and the 10th row (the last available value) is Index 9 not Index 10 - Index 10 does not exist.

Your problem is exactly due to this, you have a cursor of two rows (index 0 through 1), and you are attempting to access index 2 (a third item that simply isn't there), therefore you get an exception thrown.

Hope that helped.

0

精彩评论

暂无评论...
验证码 换一张
取 消