Question

I am working to an Android app that displays the missed calls using:

String[] projection = new String[]{
    CallLog.Calls.NUMBER,
    CallLog.Calls.TYPE,
    CallLog.Calls.DURATION,
    CallLog.Calls.CACHED_NAME,
    CallLog.Calls._ID
};

String where = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.NEW + "=1" ;         
Cursor c = context.getContentResolver().query(
    CallLog.Calls.CONTENT_URI,
    projection,
    where,
    null,
    null
 );
c.moveToFirst();    
if (c.getCount() > 0) newCountersObj.missedCallCounter = c.getCount();

After checking the missed calls in my android listview I want to mark them as read in android DB. How can I do that?

Question update with the following link:

clear missed calls error in android.database.SQLite

Was it helpful?

Solution

By setting is_read flag to true. Reference: http://developer.android.com/reference/android/provider/CallLog.Calls.html#IS_READ

Example (from ClearMissedCallsService):

    // Clear the list of new missed calls.
    ContentValues values = new ContentValues();
    values.put(Calls.NEW, 0);
    values.put(Calls.IS_READ, 1);
    StringBuilder where = new StringBuilder();
    where.append(Calls.NEW);
    where.append(" = 1 AND ");
    where.append(Calls.TYPE);
    where.append(" = ?");
    context.getContentResolver().update(Calls.CONTENT_URI, values, where.toString(),
            new String[]{ Integer.toString(Calls.MISSED_TYPE) });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top