Xamarin.Android 使用 SQLite 出现 Index -1 requested, with a size of 10 异常
异常: Android.Database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 10

此错误是数据返回到ICursor无法确定获取列的索引,那么需要加上一下代码即可。
if (i == ) //确定游标位置
{
ic.MoveToFirst();
}
else
{
ic.MoveToNext();
}
完整代码Demo:
/// <summary>
/// 查询数据
/// </summary>
void QueryData()
{
ICursor ic = Localhost_DataBase.Query("tb_person", null, null, null, null, null, null);
for (int i = ; i < ic.Count; i++)
{
if (i == ) //确定游标位置
{
ic.MoveToFirst();
}
else
{
ic.MoveToNext();
} person = new Person();
person.Id = ic.GetString(ic.GetColumnIndex("Id"));
person.Name = ic.GetString(ic.GetColumnIndex("name"));
person.Age = ic.GetString(ic.GetColumnIndex("age"));
person.Sex= ic.GetString(ic.GetColumnIndex("sex"));
person.IdCard = ic.GetString(ic.GetColumnIndex("idcard"));
list.Add(person);
}
lv_Person.Adapter = new ListViewAdapter(this, list);
}
Xamarin.Android 使用 SQLite 出现 Index -1 requested, with a size of 10 异常的更多相关文章
- 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()){// ...
- android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3
今天在写一个小项目的数据库部分的功能时,出现了一个这样的问题:java.lang.RuntimeException: Failure delivering result ResultIn ...
- Xamarin android使用Sqlite做本地存储数据库
android使用Sqlite做本地存储非常常见(打个比方就像是浏览器要做本地存储使用LocalStorage,貌似不是很恰当,大概就是这个意思). SQLite 是一个软件库,实现了自给自足的.无服 ...
- 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 ...
- Xamarin.Android之SQLite.NET ORM
一.前言 通过<Xamarin.Android之SQLiteOpenHelper>和<Xamarin.Android之ContentProvider>的学习,我们已经掌握了如何 ...
- 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 ...
- 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 ...
- Xamarin.Android开发实践(十四)
Xamarin.Android之ListView和Adapter 一.前言 如今不管任何应用都能够看到列表的存在,而本章我们将学习如何使用Xamarin去实现它,以及如何使用适配器和自定义适配器(本文 ...
随机推荐
- 测验2: Python基础语法(上) (第4周)
快乐的数字 描述 编写一个算法来确定一个数字是否“快乐”. 快乐的数字按照如下方式确定:从一个正整数开始,用其每位数的平方之和取代该数,并重复这个过程,直到最后数字要么收敛等于1且一直等于1,要么将无 ...
- js控制easyui文本框例子及控制html例子
easyui $('#value').textbox('setValue',''); //赋值 $('#value').textbox({required:false});//必填,方框变红 $('# ...
- layui超链接追加tab选项卡必须手动刷新才出现问题
在admin.js中tabAdd方法里 var li = $("#WeTabTip li[lay-id=" + id + "]").length;中的id外面加 ...
- Add custom field in Material Master
1.Add fields in the Append Structure of table MARA. 2.Configure SPRO IMG -> Logistics General -&g ...
- [leetcode]50. Pow(x, n)求幂
Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Input: 2.00000, 10 Ou ...
- java_22 Map接口
1Map Collection是孤立存在的,向集合中存储元素是一个一个放进去的 Map中的集合存储是成对的,可以通过键找到值.即将键映射到值的对象.一个映射不能包含重复的键:每个键最多只能映射到一个值 ...
- c#mysql批量更新的两种方法
总体而言update 更新上传速度还是慢. 1: 简单的insert 速度稍稍比MySqlDataAdapter慢一点 配合dapper 配置文件 <?xml version="1 ...
- java多线程系列7 高级同步工具(1)信号量Semaphore
Semaphore叫做信号量 可以控制某个资源可被同时访问的个数, acquire() 获取一个许可,得到许可才能执行后面的代码,如果没有就等待. release() 释放一个许可. 当信号量的只允许 ...
- SIFT算法
备注:源代码还未理解,所以未附上——下周任务 一.SIFT算法 1.算法简介 尺度不变特征转换即SIFT (Scale-invariant feature transform)是一种计算机视觉的算法 ...
- ABP框架系列之四:(Repositories-仓库)
"Mediates between the domain and data mapping layers using a collection-like interface for acce ...