使用游标的内部连接生成另一个Cursor对象 [英] Inner join with Cursors resulting another Cursor object
问题描述
其实我有2 Cursor
一个是SQLite游标,另一个来自 ContentProvider
复杂的SQLite查询 - 但我没有访问它。
两个游标都有相同的唯一 _ID
字段。在纯SQL中,使用这些id字段很容易加入它们,但是在我的情况下不行,因为第二个游标不是SQLite查询。
我需要生成结果加入 Cursor
。 CursorJoiner
或 MergeCursor
都不能帮助我。
选项#1:编写自己的实现 Cursor / code> - 也许扩展
AbstractCursor
- 执行连接。我在已停用的图书的旧版本中显示了一些古代码参见第186-190页)。
选项#2:创建代表加入的 MatrixCursor
>
In fact I have 2 Cursor
s one is SQLite cursor, another one comes from ContentProvider
- beneath it lies complicated SQLite query - but I don't have access to it.
Both cursors has the same unique _ID
field. In a pure SQL it would be really easy to join them using those id field, but not in my case, since 2nd Cursor is not SQLite query.
I need to produce resulting joined Cursor
. Neither CursorJoiner
nor MergeCursor
doesn't help me.
Any ideas, clues, hints?
Option #1: Write your own implementation of Cursor
-- perhaps extending AbstractCursor
-- that does the join. I have some ancient code in an obsolete version of a discontinued book that demonstrates this (see pages 186-190).
Option #2: Create a MatrixCursor
that represents the join.
这篇关于使用游标的内部连接生成另一个Cursor对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!