How can you clear the entire call log history in android? Currently i have this code that can only clear a particular call log
public void DeleteCallLogByNumber(String number) {
String queryString="NUMBER="+number;
this.getContentResolver().delete(CallLog.Calls.CONTENT_URI,queryString,null);
}
}
I was able to do it with this, It's been a while though. Not sure if this still works.
getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI, null, null) ;
EDIT: Please note I am not certain that the platform designers intended for apps to be able to delete the call log See this dev blog post. So while this does technically work please take this as a fair warning that it may at any point change and break what you are trying to build.
You cannot delete all with a single API call.
You can, however, delete them one-by-one (as mentioned in the comments) by looping through them all. To do that, you'll want to use a Cursor
. Keep in mind: that link only wipes out calls of less than 60 seconds, so you'll have to modify the Cursor
creation to delete all calls instead.
Also note: For APIs 11+, you should be using CursorLoader
instead of managedQuery(...)
.
Try this:
String queryString="DURATION >= 0";
this.getContentResolver().delete(android.provider.CallLog.Calls.CONTENT_URI, queryString, null);