我有2个不同的数据集,他们每个人用自己的的ContentProvider
。查询到他们,我可以得到2个不同的游标。这些2光标有2个不同的主键,但有一个相同的字段( DATE
),我可以使用排序(其它领域是不同的)。
I have 2 different sets of data, each of them use its own ContentProvider
. Querying to them I can get 2 different cursors. Those 2 cursors has 2 different primary keys, but there's one and the same field (DATE
) which I can use for ordering (other fields are different).
我的目标是有一个最终的合并光标
这将是由那些 DATE
字段进行排序。我已经调查 MergeCursor
,但它不适合我,因为它返回的合并/连接起来(但没有排序光标
)。
My goal is to have one final merged Cursor
which will be sorted by those DATE
field. I have investigated MergeCursor
but it doesn't fit to me, since it returns merged/concatenated (but not sorted Cursor
).
任何想法,线索?
推荐答案
您可以试试这个类从AOSP版本库:https://android.googlesource.com/platform/frameworks/base.git/+/android-4.4.4_r1/core/java/com/android/internal/database/SortCursor.java
You can try this class from AOSP repository: https://android.googlesource.com/platform/frameworks/base.git/+/android-4.4.4_r1/core/java/com/android/internal/database/SortCursor.java
有一个性能警告在类的开始,但如果你没有10K或100K的记录可能被罚款。
There is a performance warning at the beginning of the class but if you don't have 10K or 100K records it might be fine.
相关推荐
最新文章