异常: 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 异常的更多相关文章

  1. 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()){// ...

  2. android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 3

           今天在写一个小项目的数据库部分的功能时,出现了一个这样的问题:java.lang.RuntimeException: Failure delivering result ResultIn ...

  3. Xamarin android使用Sqlite做本地存储数据库

    android使用Sqlite做本地存储非常常见(打个比方就像是浏览器要做本地存储使用LocalStorage,貌似不是很恰当,大概就是这个意思). SQLite 是一个软件库,实现了自给自足的.无服 ...

  4. 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 ...

  5. Xamarin.Android之SQLite.NET ORM

    一.前言 通过<Xamarin.Android之SQLiteOpenHelper>和<Xamarin.Android之ContentProvider>的学习,我们已经掌握了如何 ...

  6. Android android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1

    Android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的. 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值. 下面的代码会返回错误 U ...

  7. android.database.CursorIndexOutOfBoundsException: Index <m> requested, with a size of <n>

    遇到这样的问题比较郁闷,造成上述问题的原因也是多种多样的. 总结一下原因: 1:得到cursor对象,没有moveToPosition()或者moveToNext()等游标操作就进行cursor.ge ...

  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. Xamarin.Android开发实践(十四)

    Xamarin.Android之ListView和Adapter 一.前言 如今不管任何应用都能够看到列表的存在,而本章我们将学习如何使用Xamarin去实现它,以及如何使用适配器和自定义适配器(本文 ...

随机推荐

  1. 298. Binary Tree Longest Consecutive Sequence最长连续序列

    [抄题]: Given a binary tree, find the length of the longest consecutive sequence path. The path refers ...

  2. [leetcode]2. Add Two Numbers两数相加

    You are given two non-empty linked lists representing two non-negative integers. The digits are stor ...

  3. ubuntu6.4系统安装JIRA-7.8

    一.系统环境: system version:ubuntu6.4 openjdk version  (java版本) :1.8.0_191  mysql version:14.14 jira vers ...

  4. PHP导出Excel表

    <?php/** * Created by PhpStorm. * User: admin * Date: 2019/3/16 * Time: 9:41 *///利用excel导出插件PHPEx ...

  5. (百度)centos7上安装apache指南

    https://jingyan.baidu.com/album/c843ea0bb5ff3977931e4a14.html?picindex=1 原文就不拷贝了.留个网址

  6. sql server导出大批量数据

    使用sqlserver导出数据的时候,如果数据量大于65536那么就要使用xlsx,最大行数为104万 如果导出的时候报错,则需要在本机安装以下程序: https://www.cnblogs.com/ ...

  7. 【APP测试(Android)】--功能

  8. chrome升级后出现滚动条无法滚动

    最近升级chrome最新版本后,导致项目中功能页面的局部滚动条无法滚动(心里暗骂了很久),无论怎么滚动都是最外层的滚动条响应... 1.猜想:尼玛google应该不会干事件流混乱这种事,pass: 2 ...

  9. Codeforces Round #546 (Div. 2) E 推公式 + 线段树

    https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...

  10. leetcode(java)

    86 class Solution { public ListNode partition(ListNode head, int x) { ListNode lowheader=new ListNod ...