【问题标题】:Delete call log in android for particular number在android中删除特定号码的通话记录
【发布时间】:2012-12-24 09:49:06
【问题描述】:

我正在尝试删除特定号码的所有通话记录。

try {
    String strNumberOne[] = {number};
    Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, CallLog.Calls.NUMBER + "=? ", strNumberOne, "");
    boolean bol = cursor.moveToFirst();
    if (bol) {
        do {
            int idOfRowToDelete = cursor.getInt(cursor.getColumnIndex(CallLog.Calls._ID));                            
            getContentResolver().delete(Uri.withAppendedPath(CallLog.Calls.CONTENT_URI, String.valueOf(idOfRowToDelete)), "", null);
        } while (cursor.moveToNext());
    }
} catch (Exception ex) {
    System.out.print("Exception here ");
}

我想触发LIKE 查询,因为保存在 callLog 中的 mobNum 是 +916666666666,我传递的号码是 6666666666。所以它不匹配。谁能帮我解决这个问题?

【问题讨论】:

    标签: java android calllog


    【解决方案1】:

    尝试使用此代码从历史记录中删除任何特定数字

    String number="4666";//any number
    Uri CALLLOG_URI = Uri.parse("content://call_log/calls"); 
    context.getContentResolver().delete(CALLLOG_URI,CallLog.Calls.NUMBER +"=?",new String[]{number});
    

    您也可以按用户名删除通话记录

    context.getContentResolver().delete(CALLLOG_URI,CallLog.Calls.CACHED_NAME +"=?",new String[]{name});
    

    【讨论】:

      【解决方案2】:

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      相关资源
      最近更新 更多