android sqlite android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5
2024-10-11 09:21:27
Cursor c = db.query("user",null,null,null,null,null,null);//查询并获得游标
if(c.moveToFirst()){//判断游标是否为空
for(int i=0;i<c.getCount();i++){
c.move(i);//移动到指定记录
String username = c.getString(c.getColumnIndex("username");
String password = c.getString(c.getColumnIndex("password"));
}
}
在通过以上代码读取sqlite user表中多条数据时,就会发生错误:android sqlite android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5。我把上面代码改成以下:
Cursor c = db.query("user",null,null,null,null,null,null);//查询并获得游标 for(int i=0;i<c.getCount() && c!=null ;i++){
if(c.moveToFirst()){//判断游标是否为空
c.move(i);//移动到指定记录
String username = c.getString(c.getColumnIndex("username");
String password = c.getString(c.getColumnIndex("password"));
}
}
OK,睡觉了。
最新文章
- 06.SQLServer性能优化之---数据库级日记监控
- BootStrap_03之组件(手风琴、导航)
- MapReduce、Hbase接口API实践
- node Later定时任务
- xcode duplicate symbol _GAD_MD5 解决方法
- iOS 单元測试之XCTest具体解释(一)
- HDU 5889 Barricade
- JSP简单标签标签库开发
- docker网络访问(三)
- RobotFramework自动化测试框架-移动手机自动化测试Click A Point关键字的使用
- ROS_Kinetic_x 基於ROS和Gazebo的RoboCup中型組仿真系統(多機器人協作)
- CentOS 常用Linux命令
- 1K star+ 的项目是如何炼成的?
- zookeeper安装教程(zookeeper3.4.5为例)
- 一文看懂大数据的技术生态Hadoop, hive,spark都有了[转]
- Java数据类型Stack栈、Queue队列、数组队列和循环队列的比较
- [MySQL]查看用户权限与GRANT用法
- Groovy学习笔记(1)读取CSV文件
- SQLServer分页查询笔记
- 蓝牙disable流程简述
热门文章
- Dynamics CRM Form表单中通过javascript抓取触发change事件字段的属性名
- javascript语法之循环语句
- 学习pthreads,使用条件变量进行多线程之间的同步
- hadoop上C++开发两种方式的例子
- android重启代码
- Lucene 学习资料
- Leetcode_278_First Bad Version
- HBase多次加载-ROOT-和META的bug
- obj-c编程10:Foundation库中类的使用(4)[文件管理,查询当前进程信息]
- Which SQL statement is the trump card to the senior software developer