【问题标题】:error: incompatible types: int cannot be converted to Uri错误:不兼容的类型:int 无法转换为 Uri
【发布时间】:2017-08-19 20:46:28
【问题描述】:

我正在尝试更新我的 DB int cannot be converted to Uri,但没有插入 int 值

insertedUri = getApplicationContext().getContentResolver().update(
                    pm2_Contract.pm2_MoviesEntry.pm2_buildMoviesUri(100),
                    locationValues,
                    "Movie_ID_test",
                    null);

pm2_buildMoviesUri 返回url的方法:

public static Uri pm2_buildMoviesUri(long id) {
        return ContentUris.withAppendedId(pm2_CONTENT_URI, id);
    }

locationValues 代码也是:

ContentValues locationValues = new ContentValues();

【问题讨论】:

    标签: android sqlite sql-update


    【解决方案1】:

    SQLite update 操作返回受影响行的计数 (int),而不是 URI。所以,在下一个作业中:

    insertedUri = getApplicationContext().getContentResolver().update(
                    pm2_Contract.pm2_MoviesEntry.pm2_buildMoviesUri(100),
                    locationValues,
                    "Movie_ID_test",
                    null);
    

    insertedUri 包含受数据库更新操作影响的行计数值。

    【讨论】:

    • 确定这是我必须做的,我什至不问,我只是想获得网站的批准,谢谢你,祝你有美好的一天
    猜你喜欢
    • 2017-10-03
    • 2019-04-18
    • 2018-05-28
    • 2016-09-05
    • 2023-01-18
    • 2019-08-22
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多