views:

328

answers:

1

I get records from the system by quering a ContentResolver. I maintain the order of the items in the database. So I want to display the items in the order taken from my database.

How do I merge these two informations?

EDIT 1

I am looking after an alternative way now. As what I ideally want is:

  • get order of contacts by a custom order held in my database (this involves joining CR with my DB cursor, and doing an order by, later seams it's not possible with CursorJoiner)
  • but there is more, if the join is not unique I want to sort by contact's name as last measure

which is impossible using Cursor and Joiners, because of the missing feature of order bys, also I need to return a Cursor, as I will be using the in an ExpandableList

Also this translated to TSQL it would look like

select * from contactsdata 
left join category on contactsdata.catid=category.id
order by category.pos asc, contact.display_name asc

So I am looking now after an alternative.
I have in mind to load in a temporary DB table all data from CR, then do the query on the temporary table where I can join tables and do order bys? How does this sound to you?

+3  A: 

Take a look at CursorJoiner.

If that doesn't work, you can roll your own equivalent with a fair amount of pain, whiskey, or both.

CommonsWare
Seems like you are in a good mood. :)
alex
Nah, that's just the whiskey talking. :-) More seriously, I *have* rolled my own, and it's a fair bit of code to sling. It's certainly doable, but not the sort of thing you want to do if you can avoid it.
CommonsWare
Check my edit to the original question, and my approach to load all CR data into a temporary table to run query on it.
Pentium10
I think your data model is waaaaaaaaaaaaaaaaaaay too complicated for a mobile device. :-) Beyond that, though, your only options are the one you described or doing all the join operations yourself in Java (e.g., to populate a `MatrixCursor`).
CommonsWare
OK will see what I can do. Unfortunately I know the modal is too complicated, but also doesn't stop at this level. I am doing some augmented/multi-level sort order and kinda hard to put it together with CR.
Pentium10