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

Android错误总结-E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column 'id' d
www.MyException.Cn   发布于:2013-03-17 13:48:31   浏览:25次
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 ?,?

你可能感兴趣的:(Android错误总结-E/AndroidRuntime(23439): Caused by: java.lang.IllegalArgumentException: column 'id' d)