views:

108

answers:

3

Hi,

I'm wondering if there's any way to merge two cursors together and then resort them.

I can easily merge two cursors together by using a MergedCursor, but that doesn't sort them.

I have two sets of contacts in two separate cursors (with totally different schemas) and I want to merge them and sort them by name (the name column is different in the two cursors).

Is this possible?

Thanks,

Tony

+1  A: 

Perhaps you should rather create an SQL query that returns a cursor that contains all data that you want to view than to create two different query and try to merge them once you have a cursor?

Christian
I don't think that's possible (although if it is, let me know).Basically the app has it's own database that holds contacts only for the app, but I also query the phone's contact database for native contacts. Thanks for the response!
tonyc
A: 

As a lengthy, probably not very efficient solution, you could use this combined cursor to create another databse, and sort from that query. Otherwise just add the items from the native phone contacts to your database periodically or something?

mbauer14
A: 

You can use SortCursor from android sources with slight modifications (different column names), see http://android.git.kernel.org/?p=platform/packages/apps/Gallery3D.git;a=blob;f=src/com/cooliris/media/SortCursor.java

thevery