1

I want to get the particular call type alone and delete it from the call log in android.

while (cursor.moveToNext()) { 
  String queryString1= "CallType=’" + CallLog.Calls.MISSED_TYPE + "‘"; 
  Log.v("CallType", queryString1); 
  if(CallLog.Calls.TYPE.equals("missed")) {
    sb.append("Number "+CallLog.Calls.NUMBER+"\nName "+CallLog.Calls.CACHED_NAME);
  }
}
getContentResolver().delete(UriCalls, CallLog.Calls.MISSED_TYPE, null);

This is a code i ve tried for missed call,because of Missed_type is int, i got an error "The method delete(Uri, String, String[]) in the type ContentResolver is not applicable for the arguments (Uri, int, null)"

Give me some tips to delete the particular call type from log

yorkw
  • 40,926
  • 10
  • 117
  • 130
user186145
  • 11
  • 1
  • 2

1 Answers1

1

you can use following code to fetch Missed call Alert

final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = android.provider.CallLog.Calls.DATE + " DESC";
Cursor cursor = null;
try{
    cursor = context.getContentResolver().query(
         Uri.parse("content://call_log/calls"),
         projection,
         selection,
         selectionArgs,
         sortOrder);
 while (cursor.moveToNext()) { 
     String callLogID =           cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
    String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
    String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
    String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
    String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
    if(Integer.parseInt(callType) == MISSED_CALL_TYPE && Integer.parseInt(isCallNew) > 0){
        if (_debug) Log.v("Missed Call Found: " + callNumber);
    }
 }
} catch(Exception ex){
 if (_debug) Log.e("ERROR: " + ex.toString());
}finally{
 cursor.close();
}

You can also use this link http://android2011dev.blogspot.in/2011/08/get-android-phone-call-historylog.html

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

Give above permission in androidmanifest.xml

use following link to delete missed call list , you just need to pass number that u got from above code

http://www.mobisoftinfotech.com/blog/android/androidcalllogdeletion/

Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69