出错原因:在查询整个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. Oracle_PL/SQL(7) 集合

    pl/sql集合处理单行单列数据,可以使用标量变量:处理单行多列的数据,可以使用pl/sql记录(%rowtype,record):处理单列多行数据,可以使用pl/sql集合. pl/sql集合类型是 ...

  2. 前端面试问题css汇总

    1,行内元素有哪些?块级元素有哪些?空元素有哪些?CSS的盒模型? 块级元素:div p h1 h2 h3 h4 form ul li 行内元素: a b br i span input select ...

  3. 转录组分析综述A survey of best practices for RNA-seq data analysis

    转录组分析综述 转录组 文献解读 Trinity cufflinks 转录组研究综述文章解读 今天介绍下小编最近阅读的关于RNA-seq分析的文章,文章发在Genome Biology 上的A sur ...

  4. 05. pt-diskstats

    pt-diskstats --devices-regex=sda --interval=1 --iterations=3 --show-timestamps #ts device rd_s rd_av ...

  5. BUG(1):一个关于指针的bug

    是时候记录一下这个让我栽了两次的bug了. 具体情况如下: #include <stdio.h>#include <stdlib.h> struct app_info_t { ...

  6. Carbon document

    <   Getting Started Docs Reference History Contribute Github Introduction The Carbon class is inh ...

  7. android 打开新窗口

    ImageView loginBtn = (ImageView)findViewById(R.id.login_button); loginBtn.setOnClickListener(new Vie ...

  8. fastcgi vc6.0demo

    #include <WinSock2.h> #include <stdio.h> #pragma comment(lib, "ws2_32.lib") ty ...

  9. 嵌入式C编程代码优化笔记

    [优化永远是追求某种平衡而不是走极端,优化是有侧重点的,优化是一门平衡的艺术,它往往要以牺牲程序的可读性或者增加代码长度为代价] 1.选择合适的算法和数据结构 选择一种合适的数据结构很重要,如果在一堆 ...

  10. python学习 day15 (3月20日)----time

    # '2019-03-20 10:40:00'#这个时间向后推一个月 f1 = time.strptime('2019-03-20 10:40','%Y-%m-%d %H:%M') # 把字符串时间转 ...