我实现了一个列表,其项目是从数据库中获取的,当我单击下一页上的项目时,我希望它向我显示有关该项目的信息,该项目存储在一个数据库行中。但是no such :name
会出现问题。
我检索该行的代码是:
public Cursor getPerson(String name) throws SQLException
{
Cursor mCursor =
db.query(true, Constants.TABLE_NAME, null, Constants.PERSON_NAME + "=" + name, null, null,null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
我点击该项目的代码是:
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
db.open();
try{
Cursor c=db.getPerson(mAdapter.getItem(position));
p.setName(c.getString(c.getColumnIndex(Constants.PERSON_NAME)));
p.setAccount(c.getLong(c.getColumnIndex(Constants.ACCOUNT)));
if(c.getInt(c.getColumnIndex(Constants.TYPE))>0)
p.setType(true);
else
p.setType(false);
Intent intent =new Intent(Main.this, Person_page.class);
intent.putExtra("com.pooya.dongali.Main", p);
startActivity(intent);
}catch(SQLException ex){
ex.printStackTrace();
}
db.close();
}