我正在尝试查询我的数据库以返回输入到文本框中的名称。我已经能够查看数据库中的所有项目,但我想使用文本框搜索名称。当我输入名称并点击搜索按钮时,日志猫显示错误“没有这样的列:john:编译时:SELECT name, gender, height, age, hair FROM details WHERE name= john ORDER by name.
private void findRecords(){
EditText find = (EditText)findViewById(R.id.nameSearch);
EditText name = (EditText)findViewById(R.id.nameFound);
EditText gender = (EditText)findViewById(R.id.genderFound);
String s = find.getText().toString();
//Long l = Long.parseLong(s);
DatabaseClass hon = new DatabaseClass(this);
String returnedName = hon.getName(s);
String returnedGender = hon.getGender(s);
name.setText(returnedName);
gender.setText(returnedGender);
}
public String getName(String s) {
// TODO Auto-generated method stub
String[] columns = new String[] {NAME_COLUMN, GENDER_COLUMN, HEIGHT_COLUMN, AGE_COLUMN, HAIR_COLUMN};
Cursor c = sherlockdb.query(TABLE_NAME, columns, NAME_COLUMN +"="+ s, null, null, null, NAME_COLUMN);
if (c != null){
c.moveToFirst();
String name = c.getString(1);
return name;
}
return null;
}
请帮助