public static boolean expressionIsValidSQl(String filter){
  if (filter == null) {
    return true;
  }
  if (TextUtils.containsAnyIgnoreCase(filter,ILLEGAL_SQL_KEYWORDS)) {
    return false;
  }
  for (int i=0; i < filter.length(); i++) {
    char ch=filter.charAt(i);
    if (!(Character.isWhitespace(ch) || Character.isLetterOrDigit(ch) || SQL_VALID_CHARS.contains(ch))) {
      return false;
    }
  }
  return true;
}

public static boolean expressionIsValidSQl ( String filter ) { if ( filter == null ) { return true ; } if ( TextUtils . containsAnyIgnoreCase ( filter , ILLEGAL_SQL_KEYWORDS ) ) { return false ; } for ( int i = 0 ; i < filter . length ( ) ; i ++ ) { char ch = filter . charAt ( i ) ; if ( ! ( Character . isWhitespace ( ch ) || Character . isLetterOrDigit ( ch ) || SQL_VALID_CHARS . contains ( ch ) ) ) { return false ; } } return true ; }
validates whether a filter expression contains malicious code such as sql injection attempts .
