如何在ormlite的查询中忽略撇号(')

时间:2015-01-07 09:43:02

标签: java android sqlite ormlite

我的代码是: -

QueryBuilder<PatientDetails, Integer> qb = patientDao.queryBuilder();
qb.where().like("patientname", "%" + searchItem + "%");
patientsDetailsLit = patientDao.query(qb.prepare());

如果searchItem内容撇号(')则代码将崩溃。

1 个答案:

答案 0 :(得分:3)

尝试Select Arguments

QueryBuilder<PatientDetails, Integer> qb = patientDao.queryBuilder();
SelectArg selectArg = new SelectArg();
qb.where().like("patientname", selectArg);
selectArg.setValue("%" + searchItem + "%");
patientsDetailsLit = patientDao.query(qb.prepare());