2017-08-23 4 views
0

アンドロイドのデフォルトメールは、件名、送信者、または受信者によってフィルタリングされます。しかし、コンテンツでフィルタリングする方法は?メッセージ本体はデータベースに保存されません。この本体はAndroid 5.0以降のファイルに保存されます。私はメッセージ本体をデータベースに入れるべきですか?それはAndroid 5.0の前に好きですか?キーワードに基づいてコンテンツをフィルタリングしますか?いくつかのアドバイスをくれ、ありがとう!アンドロイドのコンテンツでメールをフィルタリングする方法は?

case BODY: 
       final ContentValues dbValues = new ContentValues(values); 
       // Prune out the content we don't want in the DB 
       dbValues.remove(BodyColumns.HTML_CONTENT); 
       dbValues.remove(BodyColumns.TEXT_CONTENT); 
       // TODO: move this to the message table 
       longId = db.insert(Body.TABLE_NAME, "foo", dbValues); 
       resultUri = ContentUris.withAppendedId(uri, longId); 
       // Write content to the filesystem where appropriate 
       // This will look less ugly once the body table is folded into the message table 
       // and we can just use longId instead 
       if (!values.containsKey(BodyColumns.MESSAGE_KEY)) { 
        throw new IllegalArgumentException(
          "Cannot insert body without MESSAGE_KEY"); 
       } 
       final long messageId = values.getAsLong(BodyColumns.MESSAGE_KEY); 
       // Ensure that no pre-existing body files contaminate the message 
       deleteBodyFiles(context, messageId); 
       writeBodyFiles(getContext(), messageId, values); 
       break; 


public static String buildLocalSearchSelection(Context context, long mailboxId, 
      String queryFilter, String queryFactor) { 
     StringBuilder selection = new StringBuilder(); 
     selection.append(" ("); 
     queryFilter = queryFilter.replaceAll("\\\\", "\\\\\\\\") 
       .replaceAll("%", "\\\\%") 
       .replaceAll("_", "\\\\_") 
       .replaceAll("'", "''"); 
     String[] queryFilters = queryFilter.split(" +"); 

     boolean isAll = false; 
     if (queryFactor.contains(SearchParams.SEARCH_FACTOR_ALL)) { 
      isAll = true; 
     } 
     if (queryFactor.contains(SearchParams.SEARCH_FACTOR_SUBJECT) || isAll) { 
      selection.append(buildSelectionClause(queryFilters, MessageColumns.SUBJECT)); 
     } 
     if (queryFactor.contains(SearchParams.SEARCH_FACTOR_SENDER) || isAll) { 
      selection.append(buildSelectionClause(queryFilters, MessageColumns.FROM_LIST)); 
     } 
     if (queryFactor.contains(SearchParams.SEARCH_FACTOR_RECEIVER) || isAll) { 
      selection.append(buildSelectionClause(queryFilters, null)); 
     } 

     selection.delete(selection.length() - " or ".length(), selection.length()); 
     selection.append(")"); 
     return selection.toString(); 
    } 

答えて

0

電子メールコンテンツをフィルタリングするのに 'MessageColumns.SNIPPET'を使用できます。

関連する問題