android.database.sqlite.SQLiteDatabase.insert(...) 返回的 long 是否有目的?

发布于 2024-12-13 10:38:17 字数 96 浏览 3 评论 0原文

我正在使用 SQLiteDatabase 类,但不明白为什么插入方法返回很长,因为您不能在任何其他方法(删除、查询、更新)中使用它,还是我错过了一些东西?这个id长的目的是什么?

I'm playing around with the SQLiteDatabase class and did't understand why the insert method returns a long since you cannot use it in any other method (delete, query, update) or am I missing something? What's is the purpose of this id long?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨落□心尘 2024-12-20 10:38:17

那个 long 就是新插入行的行 ID。是的,您可以在 deletequeryupdate 方法中使用它。例如:

long id = db.insert(blah blah);
db.update("table", aContentValues, "_id = "+id, null);

That long is the row ID of the newly inserted row. And yes, you can use it in delete, query and update methods. For instance:

long id = db.insert(blah blah);
db.update("table", aContentValues, "_id = "+id, null);
脱离于你 2024-12-20 10:38:17

I found out the complete answer in this section from SQLite documentation http://www.sqlite.org/lang_createtable.html#rowid

国粹 2024-12-20 10:38:17

SQLite 将 INTEGER 存储为 64 位,这相当于同样为 64 位的 Java long 基本类型。

SQLite stores INTEGER as 64-bit which is equivalent to Java long primitive type at also 64-bits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文