What's the easiest way to sort a ContentResolver query by custom order?

Posted by Pentium10 on Stack Overflow See other posts from Stack Overflow or by Pentium10
Published on 2010-03-26T08:41:19Z Indexed on 2010/03/26 8:43 UTC
Read the original article Hit count: 1040

I am faceing a problem where I need to sort my ContentResolver in a custom order.

Take for example Contact Groups, you can define and manage them using Android's data database. But if you query this, you are limited to do order by on the name of the group only or id.
In my scenarion I need to sort them in an order (other than alphabetic) that I've stored in my database.

Take for example this example:

  1. Colleagues
  2. Excluded
  3. Family
  4. Friends

But the order I want them to display is:

  1. Family
  2. Colleagues
  3. Friends
  4. Excluded

So how would you accomplish this task?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sdk