0

我正在使用一个显示未接来电的 Android 应用程序:

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

在我的 android listview 检查未接来电后,我想在 android DB 中将它们标记为已读。我怎样才能做到这一点?

使用以下链接更新问题:

清除 android.database.SQLite 中的未接来电错误

4

1 回答 1

3

通过将is_read标志设置为真。参考:http: //developer.android.com/reference/android/provider/CallLog.Calls.html#IS_READ

示例(来自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) });
于 2013-05-15T09:25:57.237 回答