您好我正在尝试为我的应用程序创建一个 sqlite 查询,我需要读取一个 txt 字符串,将字符串拆分为单个单词并创建查询,这是我的代码
s= “my string with some words”;
String aWords[] = s.split(" ");
String querysearch = “body like ‘%” + aWords[0]+ "%'";
if((aWords[1] != null) && (aWords[1].length() > 3)) {querysearch = querysearch + " or body like '%" + aWords[1]+ "%'";}
if((aWords[2] != null) && (aWords[2].length() > 3)) {querysearch = querysearch + " or body like '%" + aWords[2]+ "%'";}
应用程序在这里崩溃
if((aWords[1] != null) && (aWords[1].length() > 3))
我不明白为什么,它应该只检查字符串是否为空且至少有 4 个字符长
任何帮助表示感谢