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

时间:2013-05-15 11:56:34

标签: android calllog

我有以下代码清除错过的日志:

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

运行此代码时,我收到以下异常:

Caused by: android.database.sqlite.SQLiteException: no such column: is_read, while compiling UPDATE logs SET is_read=?, new=? WHERE (new = 1 AND type = ?) AND (logtype = 100 or logtype = 500)

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

API级别14中引入了

Calls.IS_READ

如果设备API大于或等于14,则只应设置此值:

values.put(Calls.NEW, 0);
if (android.os.Build.VERSION.SDK_INT >= 14)
    values.put(Calls.IS_READ, 1);