如何重新present 2光标为1排序光标? [英] How to represent 2 cursors as 1 sorted cursor?

查看:125
本文介绍了如何重新present 2光标为1排序光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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版本库:<一href="https://android.googlesource.com/platform/frameworks/base.git/+/android-4.4.4_r1/core/java/com/android/internal/database/SortCursor.java" rel="nofollow">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.

这篇关于如何重新present 2光标为1排序光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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