如何从游标获取行ID [英] how to get a row ID from a Cursor

查看:76
本文介绍了如何从游标获取行ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从游标获取行ID?

How do I get the row ID from a Cursor?

推荐答案

我不认为Cursor直接公开此内容.
SQLiteDatabase.insert()返回新插入的行的行ID.或在Android中,约定是有一个名为"_ id" 的列,其中包含表的主要自动增量键.因此, cursor.getLong(cursor.getColumnIndex("_ id"))会检索到此.

I don't think the Cursor exposes this directly.
SQLiteDatabase.insert() returns the row id of the newly inserted row. Or in Android the convention is that there is a column named "_id" that contains the primary autoincrement key of the table. So cursor.getLong(cursor.getColumnIndex("_id")) would retrieve this.

这篇关于如何从游标获取行ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆