Delete particular log from call log

寵の児 提交于 2019-12-13 22:33:04

问题


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


回答1:


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



回答2:


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

}  


来源:https://stackoverflow.com/questions/16767671/delete-particular-log-from-call-log

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!