Search code examples
javaandroidcalllog

Delete call log in android for particular number


I am trying to delete all call logs of particular number.

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 ");
}

I want to fire a LIKE query, because the mobNum saved in callLog is +916666666666 and i am passing number 6666666666. so its not matching. can anybody help me to overcome this issue?


Solution

  • Check the following links: