出错原因:在查询整个sqlite数据库时,没有查询到 "_id" 这一列。

原来的代码是:mSQLiteDatabase.query(table_name, new String[] {_title}, null, null, null, null, null);

修改后的代码为:mSQLiteDatabase.query(table_name, null, null, null, null, null, null);

这里的 new String[] {MyEvent._title} 是一个查询条件,数组里的内容是要查询表的列名,这里是限定你要查询的列。参数值为 null 表示查询所有列(包含有 “_id” 这一列) 。如里这样改也是可以 的:mSQLiteDatabase.query(table_name, new String[] {_id, _title}, null, null, null, null, null); 目的就是要你查询的结果中含有“_id” 这一列。

另外,关于sqlite数据库中的 "_id" 这一列,在sqlite数据库中是必须有的,而且列名还必须是 “_id” 一般为主键。而用以下代码在一个ListView中显示时,也需要用到 “_id” 这一列。

public void updataAdapter() {
        if (mCursor != null && !mCursor.isClosed())
            mCursor.close();
        
        mCursor = m_MyDataBaseAdapter.fetchAllData();
        mCursor.moveToFirst();
        
        if (mCursor != null && mCursor.getCount() > 0) {
            ListAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, mCursor, new String[] { _title }, new int[] { android.R.id.text1 });
            listView.setAdapter(adapter);
        }
 }

这里的 SimpleCursorAdapter 在显示时会根据"_id"进行显示,“_id” 是必须有的。

Android Caused by: java.lang.IllegalArgumentException: column '_id' does not exist的更多相关文章

  1. java.lang.IllegalArgumentException: column '_id' does not exist问题的解决方案

    我在使用SimpleCursorAdapter的过程中遇到了问题: java.lang.IllegalArgumentException: column '_id' does not exist 这个 ...

  2. [Android]Caused by: java.lang.IllegalArgumentException: Service not registered.md

    Caused by: java.lang.IllegalArgumentException: Service not registered: org.diql.aidldemo.MainActivit ...

  3. Caused by: java.lang.IllegalArgumentException: argument type mismatch

    下面是我的报错信息 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java: ...

  4. Caused by: java.lang.IllegalArgumentException: Can not set int field reyo.sdk.enity.xxx.xxx to java.lang.Long

    由于数据库字段设置不正确引起的,不能选中 alter <table> modify <column> int unsigned; 关于unsigned int类型,可以看看它的 ...

  5. Caused by: java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for com.bj186.crm.mapper.UserMapper.Integer

    在使用SSM整合myBatis的过程中遇到了这个问题. 问题的原因: 把parameterType错误的写成了parameterMap 解决办法: 将parameterMap修改为parameterT ...

  6. mybatis报错:Caused by: java.lang.IllegalArgumentException: Caches collection already contains value for com.crm.dao.PaperUserMapper

    一.问题 eclipse启动时报下面的错误: Caused by: java.lang.IllegalArgumentException: Caches collection already cont ...

  7. 解决Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.geek.dao.ContentDao.Integer

    mybatis报错:Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain val ...

  8. 解决Caused by: java.lang.IllegalArgumentException: A universal match pattern ('/**') is defined before other patterns in the filter chain, causing them to be ignored. Please check the ordering in your

    写项目时应用了SpringSecurity框架来进行登陆验证,之前单独的写简单的SpringSecrity的Demo时并没有报错,但是当和SpringMVC一起整合时却发生了报错 报错如下: Caus ...

  9. java.sql.SQLException: Error setting driver on UnpooledDataSource.Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for IStudentDaoMapper.Mapperdao.selectcou

    是因为 Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for ...

随机推荐

  1. c#devexpress GridContorl添加进度条

    demo 的实现图 下边是步骤和代码 1定义 时钟事件,定时的增加进度条的增量. 2:  添加进度条 3;定义字段属性 using System; using System.Collections.G ...

  2. 8M - 三角形

    用N个三角形最多可以把平面分成几个区域?  Input 输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后是T组测试数据,每组测试数据只包含一个正整数N(1 ...

  3. 在电脑上查看小米手机连接wifi时保存的密码

    手机连接的wifi,想另一个手机也连上,密码忘了. 先备份手机的资料,然后将手机连上电脑,在SD卡上MIUI-backup-allbackup文件夹中, 找到刚才备份的文件夹 点进去找到WLAN设置. ...

  4. (转)在WinForm中选择本地文件

    相信很多朋友在日常的编程中总会遇到各钟各样的问题,关于在WinForm中选择本地文件就是很多朋友们都认为很难的一个学习.net的难点, 在WebForm中提供了FileUpload控件来供我们选择本地 ...

  5. iOS.PrototypeTools

    1. iPhone/iPad 原型工具 http://giveabrief.com/ 2. proto.io https://proto.io/ 3. Origami http://facebook. ...

  6. 比较两个List列表,取得List中不同项返回

    /// <summary> /// 比对模型及属性数组 /// </summary> /// <typeparam name="TM">< ...

  7. Maximum Average Subarray I LT643

    Given an array consisting of n integers, find the contiguous subarray of given length k that has the ...

  8. jQuery学习笔记:基础

    本文主要总结jQuery中一些知识点 概念 美元符号$是著名的jQuery符号.jQuery把所有功能全部封装在一个全局变量jQuery中,而$也是一个合法的变量名,它是变量jQuery的别名 $本质 ...

  9. javascript对象的属性,方法,prototype作用范围分析.

    用了javascript这么久由于没有系统学习过基础,总是拿来主义. 所以对一些基础知识还是搞不清楚很混乱. 今天自己做个小例子,希望彻底能搞清楚. 注释中对象只例子的对象本身,原型只原型继承对象的新 ...

  10. DockerDesktop简单安装和使用

    一.在windows10下,安装DockerDesktop: 1.检查windows版本为企业版或专业版,并开启Hyper-v系统设置:电脑的控制面板->程序->启用或关闭Windows功 ...