Android insertWithOnConflict返回错误的值

Android insertWithOnConflict返回错误的值,第1张

概述我在 Android / SQLite中使用insertWithOnConflict函数来插入可能已存在于数据库中的值.根据Android文档,如果值存在,将返回主键: Returnsthe row ID of the newly inserted row OR the primary key of the existing row if the input param 'conflictAl 我在 Android / sqlite中使用insertWithOnConflict函数来插入可能已存在于数据库中的值.根据AndroID文档,如果值存在,将返回主键:

Returnsthe row ID of the newly inserted row OR the primary key of the existing row if the input param 'conflictAlgorithm' = CONFliCT_IGnorE OR -1 if any error

但是,使用此函数时,如果该行已存在,则不会返回现有主键.相反,它会自动增加主键并返回该值,即使没有数据插入到返回的ID的行中.

函数调用本身相对简单:

name_ID = db.insertWithOnConflict("names",null,name_values,sqliteDatabase.CONFliCT_IGnorE);
解决方法 发生在我身边.我还看到了一些更奇怪的案例,它也归还了我0.似乎API级别存在一些问题.已经恢复为insertOrThrow,那对我来说是有用的. 总结

以上是内存溢出为你收集整理的Android insertWithOnConflict返回错误的值全部内容,希望文章能够帮你解决Android insertWithOnConflict返回错误的值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1124395.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存