gpt4 book ai didi

android - 如何从 SQLite 中检索最后一个 _ID

转载 作者:行者123 更新时间:2023-11-30 00:22:10 24 4
gpt4 key购买 nike

在我的应用程序的 SQLite 数据库上进行“插入”时,我遇到了“逻辑”问题。

这些是我的 table 。 enter image description here我应该如何管理检索 contact_idphotos_id 以便插入表 contact_photo 的“需要”?

我知道我可以使用 SELECT seq from sqlite_sequence where ... 获取 SQLite 生成的最后一个 _id,但这似乎不是一个“专业”的解决方案.

有没有更好的方法来实现我的目标?

提前致谢

最佳答案

看看这个document

long insertOrThrow (String table, 
String nullColumnHack,
ContentValues values)

将返回新插入行的行ID,如果发生错误则返回-1

关于android - 如何从 SQLite 中检索最后一个 _ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46073047/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com