Android examples for java.lang:String Contains
If String contains another string and handle null value
public class Main{ /**/*from w ww . j av a 2s . c om*/ * <pre> * StringUtil.contains(null, *) = false * StringUtil.contains(*, null) = false * StringUtil.contains("", "") = true * StringUtil.contains("abc", "") = true * StringUtil.contains("abc", "a") = true * StringUtil.contains("abc", "z") = false * </pre> * */ public static boolean contains(String str, String searchStr) { if ((str == null) || (searchStr == null)) { return false; } return str.indexOf(searchStr) >= 0; } }