Cursor类取出数据
重点是要调用 moveToFirst();
long id=intent.getLongExtra("id",0); Cursor cr =dbh.selectDataById(id); //etname.setText(cr.getString(1)); if(cr != null){ cr.moveToFirst(); } etname.setText(cr.getString(cr.getColumnIndex("name")));
另外,在使用ContextMenu的时候,如何获取数据库对应的_id呢
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item .getMenuInfo(); dbh.deleteData(info.id);