clear missed calls error in android.database.SQLite

时光毁灭记忆、已成空白 提交于 2019-12-25 05:27:20

问题


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?


回答1:


Calls.IS_READ was introduced in API level 14.

You should only set this value if the device API is greater or equal to 14 :

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


来源:https://stackoverflow.com/questions/16564376/clear-missed-calls-error-in-android-database-sqlite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!