I have one table in sqlite database which contains five different columns as shown below.
CATEGORY NOTE DATE PRICE MODE
travel delhi 10/5/2011 800 cash
food daily 9/5/2011 500 cash
travel goa 12/5/2011 1000 cash
The values in database are added by runtime from user. After all I retrieve it through content provider and store into an ArrayList and shown onto listview. But right now I want show it as per category means I want shown a category below that all its tasks then next category & its tasks like this. Item is class which contains all columnames as data members & its setter’s and getter’s. Any help will be appreciated.
Use Guava’s
MultiMaps.indexmethod. It will create a MultiMap, i.e. a Map with categories as keys, and the list of items as values.If you can’t use Guava, then do what this method does:
Map<String, List<Item>>where the key is the categoryHere’s an example: