Search code examples
javaandroidandroid-contentprovider

delete call logs not working on HTC


i m trying to delete call logs of some selected numbers , code will be run successfully with required results on emulator and two other devices (Q-Mobile A500 & Sony Ericson X10i) that i have available for testing while client test on HTC one its not working

here is my code

    String num, queryString = null;

    number = number.replace(" ", "");
    number = number.replace("-", "");
    if (number.length() > 10) {
        num = number.substring(number.length() - 10, number.length());
        queryString = " LIKE '%" + num + "%'";
    } else {
        queryString = "=" + number;
    }

    // String queryString = "NUMBER=" + number;

    Uri allCalls = Uri.parse("content://call_log/calls");

    context.getContentResolver().delete(allCalls,
            android.provider.CallLog.Calls.NUMBER + queryString, null);

     context.getContentResolver().delete(
     android.provider.CallLog.Calls.CONTENT_URI,
     android.provider.CallLog.Calls.NUMBER + queryString, null);

i m trying to delete with both queries results are same but its cant work on HTC one


Solution

  • You should delete your call log by call id may be this will help.

    int id = Activity_Name.this.getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI,"_ID = "+ calls_id_list.get(i),null);
            if (id == 1) {
                /*delete your call log*/
    
            } 
    

    may be through id you can resolve your issue.