我的团队决定使用领域作为数据库,但我有一个问题要问, Realm是否支持模糊查询,如SQLite使用关键字' like'或者'%'有时候我们需要使用模糊查询
答案 0 :(得分:5)
LIKE query is supported since 2.3.0.
public RealmQuery<E> like(String fieldName,
String value,
Case casing)
Condition that the value of field matches with the specified substring, with wildcards:
'*' matches [0, n] unicode chars
'?' matches a single unicode char.
Parameters:
fieldName - the field to compare.
value - the wildcard string.
casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.
示例:
realm.where(Person.class).like("name", "*").findAll();
realm.where(Person.class).like("name", "?ohn*", Case.SENSITIVE).findAll();