public boolean checkAllMessagesContaining(boolean check,String message){
  if (message == null || message.length() == 0) {
    return checkAllMessages(check,false);
  }
  message=Utils.makeTextSafeForSQL(message);
  SQLiteDatabase db=getWritableDatabase();
  if (db != null) {
    String likeQuery="";
    String messageNoSpace=message.replaceAll("\\s","");
    if (message.length() == 0 || messageNoSpace.length() == 0)     likeQuery=(COL_MESSAGE + " LIKE '%" + message+ "%'");
    if (likeQuery.length() == 0) {
      message=message.replaceAll("[\n\"]"," ");
      while (message.charAt(0) == ' ') {
        message=message.substring(1);
      }
      String[] words=message.split("\\s");
      for (int i=0; i < words.length; i++) {
        if (i > 0) {
          likeQuery+=" OR ";
        }
        likeQuery+=" " + COL_MESSAGE + " LIKE '%"+ words[i]+ "%' ";
      }
    }
    String parentOnly=" AND (" + COL_BIGPARENT + " IS NULL OR "+ COL_BIGPARENT+ " NOT IN (SELECT "+ COL_MESSAGE_ID+ " FROM "+ TABLE+ " WHERE "+ COL_DELETED+ "="+ FALSE+ ") AND "+ COL_PARENT+ " NOT IN (SELECT "+ COL_MESSAGE_ID+ " FROM "+ TABLE+ " WHERE "+ COL_DELETED+ "="+ FALSE+ "))";
    db.execSQL("UPDATE " + TABLE + " SET "+ COL_CHECKED+ "="+ (check ? TRUE : FALSE)+ " WHERE "+ COL_DELETED+ " ="+ FALSE+ " AND ("+ likeQuery+ ")"+ parentOnly+ ";");
    return true;
  }
  return false;
}

public boolean checkAllMessagesContaining ( boolean check , String message ) { if ( message == null || message . length ( ) == 0 ) { return checkAllMessages ( check , false ) ; } message = Utils . makeTextSafeForSQL ( message ) ; SQLiteDatabase db = getWritableDatabase ( ) ; if ( db != null ) { String likeQuery = "" ; String messageNoSpace = message . replaceAll ( "\\s" , "" ) ; if ( message . length ( ) == 0 || messageNoSpace . length ( ) == 0 ) likeQuery = ( COL_MESSAGE + " LIKE '%" + message + "%'" ) ; if ( likeQuery . length ( ) == 0 ) { message = message . replaceAll ( "[\n\"]" , " " ) ; while ( message . charAt ( 0 ) == ' ' ) { message = message . substring ( 1 ) ; } String [ ] words = message . split ( "\\s" ) ; for ( int i = 0 ; i < words . length ; i ++ ) { if ( i > 0 ) { likeQuery += " OR " ; } likeQuery += " " + COL_MESSAGE + " LIKE '%" + words [ i ] + "%' " ; } } String parentOnly = " AND (" + COL_BIGPARENT + " IS NULL OR " + COL_BIGPARENT + " NOT IN (SELECT " + COL_MESSAGE_ID + " FROM " + TABLE + " WHERE " + COL_DELETED + "=" + FALSE + ") AND " + COL_PARENT + " NOT IN (SELECT " + COL_MESSAGE_ID + " FROM " + TABLE + " WHERE " + COL_DELETED + "=" + FALSE + "))" ; db . execSQL ( "UPDATE " + TABLE + " SET " + COL_CHECKED + "=" + ( check ? TRUE : FALSE ) + " WHERE " + COL_DELETED + " =" + FALSE + " AND (" + likeQuery + ")" + parentOnly + ";" ) ; return true ; } return false ; }
set the checked state of the all messages as true or false
