SQLite 获取最后添加的条目自动递增的 id

SQLite Get last added entry autoincremented id

我通过 dBHelper.addEntry(e); 在我的 table 之一中添加了新条目 这样做之后,我需要这个新条目 "e" 的自动递增 ID,以便将它用作另一个 table 中其他条目的外键。我如何获得这个新的自动递增 ID?

假设您在 addEntry() 中使用 SQLiteDatabase#insert() - 它 return 是一个 long return 值,它是新插入行的行 ID .