我的代码是: -
QueryBuilder<PatientDetails, Integer> qb = patientDao.queryBuilder();
qb.where().like("patientname", "%" + searchItem + "%");
patientsDetailsLit = patientDao.query(qb.prepare());
如果searchItem内容撇号(')则代码将崩溃。
答案 0 :(得分:3)
QueryBuilder<PatientDetails, Integer> qb = patientDao.queryBuilder();
SelectArg selectArg = new SelectArg();
qb.where().like("patientname", selectArg);
selectArg.setValue("%" + searchItem + "%");
patientsDetailsLit = patientDao.query(qb.prepare());