当前位置: 代码迷 >> Android >> Android错误总结-E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column 'id' d
  详细解决方案

Android错误总结-E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column 'id' d

热度:288   发布时间:2016-05-01 11:18:07.0
Android异常总结---E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column '_id' d
1.在使用SimpleCursorAdapter adapter=new SimpleCursorAdapter 

(this,R.layout.item,cursor,new String[]{"name","phone","amount"},new int[] 

{R.id.name,R.id.phone,R.id.amount});这个SimpleCursorAdapter适配器的时候:
出现这个异常:
-----------------------------------------------
03-12 23:23:22.934: E/AndroidRuntime(23439): Caused by: 

java.lang.IllegalArgumentException: column '_id' does not exist

--------------------------------
这个异常跟SimpleCursorAdapter ,这个源码有关:
可以查看源码,会有说明:
---------------------------
方法:1.把数据库表中的主键id改成:_id
     2.处理查询后的结果集:主键起一个别名:
      select personid as _id,name,phone,amount from person order by personid asc 

limit ?,?

  相关解决方案