写入 Android 光标

发布于 2024-11-16 07:03:58 字数 229 浏览 5 评论 0原文

Cursor 的 Android 文档说

该接口提供随机 对结果集的读写访问 由数据库查询返回

我无法弄清楚使用游标修改值的 API。是否可以写入游标?

Android documentation for Cursor says

This interface provides random
read-write access to the result set
returned by a database query

I could not figure out what API to modify the values using a Cursor. Is it possible to write into a Cursor?

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

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

发布评论

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

评论(2

鲸落 2024-11-23 07:03:58

Android 初学者论坛上提出的类似问题的答案:

是的,有,克雷格。好问题。我很乐意提供帮助。
您可以子类化 SQLiteDatabase.CursorFactory 以从其返回
newCursor 方法,SQLiteCursor 的子类。这家工厂通过了
到 SQLiteOpenHelper 构造函数,因此,当您查询它时,它会
返回新 SQLiteCursor 子类类型的 Cursors。
然后,SQLiteCursor 子类可以公开管理它的方法
受保护的 mWindow 字段,它是一个 CursorWindow。这个对象有
putXxx 方法来操作数据。
我自己还没有尝试过,所以如果有人有任何提示或提示,
请发帖。

An answer to a similar question asked on Android Beginners forum:

Yes, there is, Craig. Good question. I'll be happy to help.
You can subclass SQLiteDatabase.CursorFactory to return, from its
newCursor method, a subclass of SQLiteCursor. This factory gets passed
to the SQLiteOpenHelper constructor so, when you query it, it will
return Cursors of your new SQLiteCursor subclass type.
The SQLiteCursor subclass can then expose methods that manage its
protected mWindow field, which is a CursorWindow. This object has
putXxx methods to manipulate the data.
I haven't tried this myself, so if anyone has any tips or hints,
please post.

一念一轮回 2024-11-23 07:03:58

无法写入游标!我想知道为什么这么说..

There is no way of writing to a cursor! I wonder why it says that..

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