Deletes all entry in call log of a specified caller number - Android Phone

Android examples for Phone:Phone Call

Description

Deletes all entry in call log of a specified caller number

Demo Code


//package com.java2s;
import android.content.Context;

import android.provider.CallLog;
import android.util.Log;

public class Main {
    private static final String TAG = "CallLogUtils";

    /***//from   w w  w.  ja  va 2  s  . co m
     * Deletes all entry in call log of a specified caller number
     * @param context      : application context
     * @param callerNumber   : caller number
     * @return            : boolean (true = entries deleted; false = no entry has deleted)
     */
    public static boolean deleteCallOfASpecifiedNumber(Context context,
            String callerNumber) {
        try {
            context.getContentResolver().delete(CallLog.Calls.CONTENT_URI,
                    android.provider.CallLog.Calls.NUMBER + "=?",
                    new String[] { callerNumber });
            Log.i(TAG, "deleted entries from Call log of callerNumber : "
                    + callerNumber);
            return true;
        } catch (Exception e) {
            Log.i(TAG, "Problem deleting Call log of callerNumber : "
                    + callerNumber);
            return false;
        }
    }
}

Related Tutorials