public void testSimpleCursorAdapter(){
//如果这样写: Cursor cursor = db.rawQuery("select id,name,password from mtb", null);
//LogCat报错: java.lang.IllegalArgumentException: column '_id' does not exist
/*
构造 Cursor 的时候需要 这个 '_id' . 所以查询返回的结果集必须有这个列名 。
有两种解决办法: 直接在建表的时候就 把主键命名为 '_id'
在查询的时候把列名给它重命名为 '_id'
如下为重命名
*/
Cursor cursor = db.rawQuery("select id _id,name,password from mtb", null);
SimpleCursorAdapter simpleCAdap = new SimpleCursorAdapter(
SimpleCursorAdapterActivity.this,
R.layout.item,
cursor,
new String[]{"name","password"},
new int[]{R.id.textView1,R.id.textView2});
listView.setAdapter(simpleCAdap);
}