Make sure the Cursor is initialized correctly before accessing data from it


详细错误是:java.lang.IllegalStateException: Couldn't read row 0, col 2 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.

出现这个原因是因为我在获取Cursor中的字段时,获取了一个不存在的字段,例如,我原本要获取数据库book表中的bookId字段,结果获取的时候写成了bookiD,

while (cursor.moveToNext()) {  
 int bookId = cursor.getInt(cursor.getColumnIndex("bookiD"));
}

注意:Android是区分大小写的,所以我们在获取的时候也要严格按照数据库表字段的大小写来获取数据

android 出现Make sure the Cursor is initialized correctly before accessing data from it的更多相关文章

  1. java.lang.IllegalStateException: Couldn't read row 1, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data fr

    Android中操作Sqlite遇到的错误:java.lang.IllegalStateException: Couldn't read row 1, col 0 from CursorWindow. ...

  2. java.lang.IllegalStateException:Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx...}: java.lang.IllegalSta ...

  3. Android开发训练之第五章第六节——Transferring Data Using Sync Adapters

    Transferring Data Using Sync Adapters GET STARTED DEPENDENCIES AND PREREQUISITES Android 2.1 (API Le ...

  4. Android 使用MediaStore.Images和 Cursor查询本地图片和图片缩略图

    先看一个实例: String[] projection = { MediaStore.Images.Thumbnails._ID ,MediaStore.Images.Thumbnails.DATA} ...

  5. Unable to load script from assets 'index.android.bundle'.make sure you bundle is packaged correctly

    解决此问题 以下方法每次都需要执行命令2才能更新 1.创建assets目录 mkdir android/app/src/main/assets 2.执行命令 react-native bundle - ...

  6. Unable to load script from assets 'index.android.bundle'.Make sure your bundle is packaged correctly or you're running a packager server

    curl -k 'http://localhost:8081/index.android.bundle?platform=android' > android/app/src/main/asse ...

  7. 收藏的技术文章链接(ubuntu,python,android等)

    我的收藏 他山之石,可以攻玉 转载请注明出处:https://ahangchen.gitbooks.io/windy-afternoon/content/ 开发过程中收藏在Chrome书签栏里的技术文 ...

  8. Xamarin.Android 使用 SQLite 出现 Couldn't read row 0, col -1 from CursorWindow. 异常

    异常:Java.Lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cu ...

  9. Android Exception 8(Couldn't read row 0, col -1 from CursorWindow)

    java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Curso ...

随机推荐

  1. Spring MVC 的核心应用-1

    使用Spring MVC实现登录.注销 配置文件applicationcontext-jdbc.xml <?xml version="1.0" encoding=" ...

  2. 安装mysql8.13用Navicat Premium链接本地数据库报2059

    推荐使用已下命令: ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则 ALTE ...

  3. jQuery表单验证的几种方法

    1.jQuery的框架的验证:validate框架 Jquery Validate 验证规则 (1)required:true 必输字段(2)remote:”check.PHP” 使用ajax方法调用 ...

  4. 【Keil】Keil5添加源程序和头文件

    xxx.c就是源程序 xxx.h就是头文件 [源程序添加方法] 双击文件夹,例如图片上的Source,跳出弹窗,选择需要添加的源程序即可 [添加头文件的方法] 1.首先点击图片红框处,或是在文件夹te ...

  5. aes并发加密Cipher not initialized 异常

    javax.crypto.Cipher 每次都要实例化,大量的实例化导致 Cipher 实例化失败. 解决办法:将已经实例化的Cipher对象,放在hashmap中,每次实例化的时候从MAP 获取,不 ...

  6. 浅谈ConcurrentHashMap实现原理

    我们都知道HashTable是线程安全的类,因为使用了Synchronized来锁整张Hash表来实现线程安全,让线程独占: ConcurrentHashMap的锁分离技术就是用多个锁来控制对Hash ...

  7. mybatis中的resultMap实际作用

    resultMap和resultType在实际的使用上完全可以进行替换,但是resultMap有比resultType更多的一个功能.我们先定义一个简单的resultMap例子 <resultM ...

  8. CSS 兼容iPhone X、iPhone XS及iPhone XR

    @media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ra ...

  9. vue.js使用axios

    使用axios的两种调用方式 1.安装axios $ cnpm install axios 2.在vue入口文件main.js中引入(推荐全局引入),或是在当前页面中引入(局部) import axi ...

  10. Java:当前线程运行完毕,再运行后续逻辑

    一.问题描述 在程序设计中,可能存在这样的情景:主线程中存在一个子线程,子线程需要在执行完毕后为后续代码逻辑提供参数.但在代码执行时,子进程还没执行完毕,后续的代码已经开始执行了,这时候就会出现参数为 ...