Question

I want to delete a particular entry from call log only once..

getActivity().getContentResolver().delete(calluri, queryString, null);

The above code delete all the entries from call log

Was it helpful?

Solution

try do delete call log by call id. use below code

int res = Call_logs.this.getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI,"_ID = "+ calls_id_list.get(i),null);
        if (res == 1) {
            // Log delete

        } else {
            // Log not Delete

        }

to delete all call log:

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

int d  = getContentResolver().delete(uri, null, null);

OTHER TIPS

STEP 1: Make sure that you have following permission in manifast.xml:

<uses-permission android:name="android.permission.READ_CONTACTS" /> 
<uses-permission android:name="android.permission.WRITE_CONTACTS" />

STEP 2: And for deleting Call logs for particular number:

public void deleteCallLogByPhoneNumber(String number) {   

    String queryString="NUMBER="+number; 
    this.getContentResolver().delete(CallLog.Calls.CONTENT_URI,queryString,null);

}  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top