index -1 requested , with a size of 1

 

访问行如下: 

int type =  blackWhiteCursor.getInt(blackWhiteCursor.getColumnIndex(Filters.TYPE));

出现log信息:

 

05-06 10:10:06.865: ERROR/AndroidRuntime(4061): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:214)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:84)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at android.database.CursorWrapper.getInt(CursorWrapper.java:123)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at cn.flyfot.filter.callfilter.RuleService.blockCommonModehandler(RuleService.java:293)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at cn.flyfot.filter.callfilter.RuleService.blockingHandler(RuleService.java:574)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at cn.flyfot.filter.callfilter.PhoneStateListenerReceiver.blockingHandler(PhoneStateListenerReceiver.java:172)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at cn.flyfot.filter.callfilter.PhoneStateListenerReceiver.doReceiver(PhoneStateListenerReceiver.java:57)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at cn.flyfot.filter.callfilter.PhoneStateListenerReceiver.onReceive(PhoneStateListenerReceiver.java:39)

05-06 10:10:06.865: ERROR/AndroidRuntime(4061):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)


解决问题:
出现以上错误是由于没有移动游标或是没有查询到需要的数据而移动了游标强制获取某一行数据而导致的,注意查询条件和右边移动。

你可能感兴趣的:(java,android)