0

I have the following code for clear missed logs:

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

When running this code I get the following exception:

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)

How to solve this?

4

1 回答 1

1

Calls.IS_READ在 API 级别 14 中引入。

仅当设备 API 大于或等于 14 时才应设置此值:

values.put(Calls.NEW, 0);
if (android.os.Build.VERSION.SDK_INT >= 14)
    values.put(Calls.IS_READ, 1);
于 2013-05-15T12:09:37.207 回答