: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 9 columns.解决

在android 数据库开发中碰到了这么一个错误:
E/CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 9 columns.
E/com.ishow.app.manager.AppManager: java.lang.RuntimeException: Unable to create service com.ishow.app.lbs.LBSService: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
                                        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3145)
                                        at android.app.ActivityThread.access$1800(ActivityThread.java:185)
                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1655)
                                        at android.os.Handler.dispatchMessage(Handler.java:111)
                                        at android.os.Looper.loop(Looper.java:194)
                                        at android.app.ActivityThread.main(ActivityThread.java:5847)
                                        at java.lang.reflect.Method.invoke(Native Method)
                                        at java.lang.reflect.Method.invoke(Method.java:372)
                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                     Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
                                        at android.database.CursorWindow.nativeGetString(Native Method)
                                        at android.database.CursorWindow.getString(CursorWindow.java:438)
                                        at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:66)
                                        at com.ishow.app.dao.impl.AccountDaoImpl.getAccount(AccountDaoImpl.java:87)
                                        at com.ishow.app.dao.impl.AccountDaoImpl.getCurrentAccount(AccountDaoImpl.java:67)
                                        at com.ishow.app.protocol.BaseProtocol.<init>(BaseProtocol.java:29)
                                        at com.ishow.app.protocol.AbstractProtocol.<init>(AbstractProtocol.java:0)
                                        at com.ishow.app.protocol.AppRecordProtocol.<init>(AppRecordProtocol.java:0)
                                        at com.ishow.app.api.AppRecordHandler.post(AppRecordHandler.java:63)
                                        at com.ishow.app.api.AppRecordHandler.post(AppRecordHandler.java:59)
                                        at com.ishow.app.lbs.LBSService.onCreate(LBSService.java:57)
                                        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3135)
                                        at android.app.ActivityThread.access$1800(ActivityThread.java:185)
                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1655)
                                        at android.os.Handler.dispatchMessage(Handler.java:111)
                                        at android.os.Looper.loop(Looper.java:194)
                                        at android.app.ActivityThread.main(ActivityThread.java:5847)
                                        at java.lang.reflect.Method.invoke(Native Method)
                                        at java.lang.reflect.Method.invoke(Method.java:372)
                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1010)
                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                                    ,version=2.2.5.14,exception time=2017-03-22  16:08:49
I/Process: Sending signal. PID: 19041 SIG: 9

Disconnected from the target VM, address: 'localhost:8611', transport: 'socket'


发生错误的主要原因是:

因为需求的变动,要在原有的数据库中新增一个字段,新增了字段后所有的工作都准备得差不多了,但忽略了一个地方,就是数据库版本还没有升级,运行后先读取数据库,没有新增的字段,进而导致以上异常的发生


解决方法:

将数据库版本升级后,在数据库版本更新方法中新增该字段,问题解决





  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值