在android中删除特定号码的呼叫记录
我想删除所有特定号码的通话记录。
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号。所以它不匹配。 任何人都可以帮助我克服这个问题吗?
检查以下链接:
- 在Android中调用日志删除
- SO:呼叫结束后从呼叫记录中删除呼叫
尝试使用此代码从历史记录中删除任何特定数字
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});