android sqlite android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5
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,睡觉了。
android sqlite android.database.CursorIndexOutOfBoundsException: Index 5 requested, with a size of 5的更多相关文章
- android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3
今天在写一个小项目的数据库部分的功能时,出现了一个这样的问题:java.lang.RuntimeException: Failure delivering result ResultIn ...
- android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1(zz)
android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1 http://blog.cs ...
- Android android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
Android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的. 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值. 下面的代码会返回错误 U ...
- android.database.CursorIndexOutOfBoundsException: Index <m> requested, with a size of <n>
遇到这样的问题比较郁闷,造成上述问题的原因也是多种多样的. 总结一下原因: 1:得到cursor对象,没有moveToPosition()或者moveToNext()等游标操作就进行cursor.ge ...
- Android开发7——android.database.CursorIndexOutOfBoundsException:Index -1 requested
android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的. 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值. 下面的代码会返回错误Us ...
- Xamarin.Android 使用 SQLite 出现 Index -1 requested, with a size of 10 异常
异常: Android.Database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 10 此错误是数据返回 ...
- 再读Android sqlite
再读Android sqlite Android原生支持sqlite数据库操作,sqlite时轻量级关系型数据库,支持标准sql语句.Android对sqlite进行良好的接口封装来避免sql注入等安 ...
- Android多线程操作sqlite(Sqlite解决database locked问题)
参考http://blog.csdn.net/sdsxleon/article/details/18259973 很好 https://github.com/2point0/Android-Data ...
- android 读取SQLite android could not open the database in read/write mode错误
由于AndroidManifest.xml文件中uses-permission没有设置权限问题 <uses-permission android:name="android.permi ...
随机推荐
- JQuery设置checkbox的值,取checkbox的值,设置radio的值,取radio的值,设置下拉选select的值,取select的值
一.复选框设置参数 html代码如下: <div class="flsm_btns"> <input type="hidden&q ...
- OC语言实现中等难度通讯录
实现中等难度通讯录.需求: 1.定义联系⼈人类Contact.实例变量:姓名(拼⾳音,⾸首字⺟母⼤大写).性别.电话号码. 住址.分组名称.年龄.⽅方法:⾃自定义初始化⽅方法(姓名.电话号码).显⽰示 ...
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二十)
下面修改最为关键的matchRun方法里的代码: CCActionCallBlock *blk = [CCActionCallBlock actionWithBlock:^{ _finishedCou ...
- Css3盒子模型-css学习之旅(5)
主要内容: 盒子模型内边距,外边距,边框,外边距合并 主要包括:margin(外边距)padding(内边距) border(边框)centent(内容) 内边距:padding,paddinglef ...
- 查看Linux系统的平均负载
1.Linux系统的平均负载的概念 有时候我们会觉得系统响应很慢,但是又找不到原因,这时就要查看平均负载了,看它是否有大量的进程在排队等待.特定时间间隔内运行队列中的平均进程数可以反映系统的繁忙程度, ...
- Pollution over East China : Image of the Day
acquired October 16, 2002download large image (2 MB, JPEG, 6000x4600) acquired October 16, 2002downl ...
- 算法面试题-leetcode学习之旅(二)
题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one di ...
- 【Qt编程】Qt学习笔记<三>
1. 如果程序中使用了png以外格式的图片,在发布程序时就要将Qt安装目录下plugins中的imagineformats文件复制到发布文件中. 2. 在函数声明处快速添加函数定义 ...
- 【翻译】了解ASP.NET MVC中的Ajax助手
原文:Understanding AJAX Helpers in ASP.NET MVC 作者: Shailendra Chauhan works as Software Analyst at rep ...
- 新IO建立的聊天程序
服务端: package com.net.scday3; import java.io.IOException; import java.net.InetSocketAddress; import j ...