关于“_id"Android SQLite 中的字段 [英] About "_id" field in Android SQLite

查看:30
本文介绍了关于“_id"Android SQLite 中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android SQLite 中是否需要字段_id"?

解决方案

_id 在您使用使用 Cursor(例如 ResourceCursorAdapter)的增强型适配器时很有用.这些适配器使用它来提供一个 ID,该 ID 可用于引用表中的特定行,该行与使用适配器的任何项目相关联(例如 ListView 中的一行).

如果您不打算在游标中使用需要 _id 列的类,则没有必要,您还可以使用as _id"使另一列看起来好像在您的游标中称为 _id.

Is the field "_id" necessary in Android SQLite?

解决方案

_id is useful when you are using the enhanced Adapters which make use of a Cursor (e.g. ResourceCursorAdapter). It's used by these adapters to provide an ID which can be used to refer to the specific row in the table which relates the the item in whatever the adapter is being used for (e.g. a row in a ListView).

It's not necessary if you're not going to be using classes which need an _id column in a cursor, and you can also use "as _id" to make another column appear as though it's called _id in your cursor.

这篇关于关于“_id"Android SQLite 中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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