Android 查找房间数据库中的字符串[]是否包含字符串

Android 查找房间数据库中的字符串[]是否包含字符串,android,sqlite,android-room,dao,Android,Sqlite,Android Room,Dao,我想在我的表中搜索具有字符串数组且应该包含字符串的表 这是我的型号 @ColumnInfo(name = DbConstants.ColumnNames.ConversationData.AGENTS_ID) @SerializedName("agentsId") public String[] agents; 这是我的打字机 @TypeConverter public String fromStringsToJson(String[] strings) { if (

我想在我的表中搜索具有字符串数组且应该包含字符串的表

这是我的型号

@ColumnInfo(name = DbConstants.ColumnNames.ConversationData.AGENTS_ID)
@SerializedName("agentsId")
public String[] agents;
这是我的打字机

 @TypeConverter
    public String fromStringsToJson(String[] strings) {
        if (strings == null)
            return null;
        return new Gson().toJson(strings);
    }

@TypeConverter
public String[] fromJsonToStrings(String string) {
    if (string == null)
        return null;

    Gson gson = new Gson();
    Type type = new TypeToken<String[]>() {
    }.getType();
    return gson.fromJson(string, type);
}

@TypeConverter
public String fromStringMapToJson(Map<String, String> map) {
    if (map == null)
        return null;

    Gson gson = new Gson();
    Type type = new TypeToken<Map<String, String>>() {
    }.getType();
    return gson.toJson(map, type);
}

@TypeConverter
public Map<String, String> fromJsonToMap(String json) {
    if (json == null)
        return null;

    Gson gson = new Gson();
    Type type = new TypeToken<Map<String, String>>() {
    }.getType();
    return gson.fromJson(json, type);
}
@TypeConverter
公共字符串fromStringsToJson(字符串[]字符串){
if(strings==null)
返回null;
返回新的Gson().toJson(字符串);
}
@类型转换器
公共字符串[]fromJSOnToString(字符串){
if(字符串==null)
返回null;
Gson Gson=新的Gson();
Type Type=new-TypeToken(){
}.getType();
返回gson.fromJson(字符串,类型);
}
@类型转换器
来自StringMapToJSON的公共字符串(映射){
if(map==null)
返回null;
Gson Gson=新的Gson();
Type Type=new-TypeToken(){
}.getType();
返回gson.toJson(map,type);
}
@类型转换器
来自JSONTOMAP的公共映射(字符串json){
if(json==null)
返回null;
Gson Gson=新的Gson();
Type Type=new-TypeToken(){
}.getType();
返回gson.fromJson(json,类型);
}
这是DAO查询

@Query("select * from conversations where channelId = :channelId AND " +
        " agentsId LIKE :agentId ORDER BY updateTimeStamp DESC")
List<ConversationData> getMyConversations(String channelId, String agentId);
@Query(“从对话中选择*,其中channelId=:channelId和”+
“agentId-LIKE:agentId-ORDER BY-updateTimeStamp-DESC”)
列出getMyConversations(字符串channelId、字符串agentId);
一切都安排得很好。我想问题是
转换器
查询


但它在字符串数组中找不到agentId。对于寻求答案的人

问题出在我的问题上。我刚刚用这个更新了它

@Query("select * from conversations where channelId = :channelId AND status = :status AND" +
            " agentsId LIKE '%' || :agentId || '%' ")
希望能有帮助