column ‘_id’ does not exist

四月 19th, 2012 没有评论 »

原因:

simpleCursorAdapter的方法只识别_id,所以,当你用到sqlite的simpleCursorAdapter时,必须把数据表的主键命名为_id。否则就会出现java.lang.IllegalArgumentException: column ‘_id’ does not exist错误。

android sqlite 插入失败

四月 19th, 2012 没有评论 »

错误如下:

android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed

 

原因,  有NOT NULL 字段 没有赋值

obtainStyledAttributes(int[]) is undefined

二月 4th, 2012 没有评论 »

为了防止这个错误“The method obtainStyledAttributes(int[]) is undefined for the type ImageAdapter”,意思是obtainStyledAttributes()是Context类中的方法,如果将ImageAdapter单独写在一个.java文件中的话,必须在obtainStyledAttributes()方法前加上方法的引用才能解决问题

出错之前:obtainStyledAttributes(R.styleable.Gallery)

改后:mContext.obtainStyledAttributes(R.styleable.Gallery)

其中  mContext 要定义

private Context mContext;

mContext = context;