android - 查找最后插入行的 id

标签 android

我必须在我的应用程序中使用 SQLite 中的简单表,我需要将值插入到我的表中,但是当我插入第一个时,我需要找到值 id(主键第一列)并将其作为第二个外键 table 。我知道用 select last 找到这个,但是有更好的方法找到这个,最后插入行的 id 吗?

最佳答案

如果您使用的是 android.database.sqlite.SQLiteDatabase,那么您可以使用 insert() 返回插入行的 ID:see here

关于android - 查找最后插入行的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8299148/

相关文章:

安卓工作室错误 : "You must install the Android Support Repository though the SDK Manager"

android - choiceMode 是否与 ExpandableListView 兼容?

javascript - 应用程序在键盘弹出窗口上搞砸了

javascript - 如何将文件从 PhoneGap/webapp ftp 到服务器?

android - Ionic App w/Cordova,如何嵌入相机?

android - iOS 和 Android 应用动态 UI 所需的技术推荐

android - 在 Android 上使用资源所有者密码凭证实现 OAuth2

android - 错误 - Google map Cordova 插件安装

android - 相对布局中添加的 fragment 下方的按钮如何可点击

android - 使用详细和调试的 Anko 日志记录不起作用