Android Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
出错原因:在查询整个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的更多相关文章
- java.lang.IllegalArgumentException: column '_id' does not exist问题的解决方案
我在使用SimpleCursorAdapter的过程中遇到了问题: java.lang.IllegalArgumentException: column '_id' does not exist 这个 ...
- [Android]Caused by: java.lang.IllegalArgumentException: Service not registered.md
Caused by: java.lang.IllegalArgumentException: Service not registered: org.diql.aidldemo.MainActivit ...
- Caused by: java.lang.IllegalArgumentException: argument type mismatch
下面是我的报错信息 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java: ...
- 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类型,可以看看它的 ...
- 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 ...
- 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 ...
- 解决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 ...
- 解决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 ...
- 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 ...
随机推荐
- Oracle_SQL(7) 复杂查询
1.rownum 伪列<,<=select * from emp where rownum<5; 取工资前3名的人员 select * from (select * from emp ...
- 抽象类,override,final和类模板
抽象类: **有些函数由于信息不够具体,而无法实现** 由此而来的纯虚函数:在基类中声明的纯虚函数,在基类中无法实现(是因为在基类中定义的信息不够具体,不是学的知识不够),于是这个函数没办法规定具体的 ...
- JS-Date心得
写在前面的话:我觉得JavaScript以后也要出像Java1.8新增的Date类,这个月份要是从1开始多好,强迫症很难受.......也就发发牢骚,没出来之前还得这么用..... 属性: const ...
- 搭建自己的代理服务 proxy nginx squid ss5 s(shadow)s(socks)
标签: nginx / squid / 负载均衡 / ss 4090 1. nginx (forward) nginx自己熟悉,经常用来做负载均衡的反向代理, 这里搭建一个正向代理(forward) ...
- Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
项目报这个错误,后来查了,是缺少ojdbc,也就是java操作oracle的包,通过https://mvnrepository.com/artifact/oracle/ojdbc/1.4,可以找到该包 ...
- boost timer代码学习笔记
socket连接中需要判断超时 所以这几天看了看boost中计时器的文档和示例 一共有五个例子 从简单的同步等待到异步调用超时处理 先看第一个例子 // timer1.cpp: 定义控制台应用程序的入 ...
- proguard-rules.pro、混淆、导jar包
前记: 买了一个<精通Android Studio>本来最想看的是关于混淆导jar包的,哪知道没有,有点小失望. 好吧,自己来. 在用Android Studio开发的时候,把minify ...
- Python3实战系列之一(获取印度售后数据项目)
问题:公司在印度开设生产工厂并在当地销售手机,生产.销售系统均由印度开发维护.对总部需要的售后数据,采用每日在ftp上提供一个.xlsx文件,给总部使用.总部需要将此数据导入到总部的销量统计系统中,以 ...
- sql条件查询-日期比较(取年月部分)
查询当年当月的数据: select * from compalete_task where to_Char(create_date,'yyyyMM') = to_Char(sysdate,'yyyyM ...
- android源码下载/查看地址
源码下载: http://git.omapzoom.org/ 高通平台android源码下载地址: https://www.codeaurora.org/xwiki/bin/QAEP/WebHome ...