android - How to do a custom sort of SQL data using Cursor & Loader? -


i have data in sqlite database , want provide basic search capabilities in listview.

here example of search query want able solve :

1) example of sqlite data :

  • ad
  • bc
  • cd
  • d
  • da
  • ec

2) input & wanted output :

  • a -> [ ad , da ]
  • d -> [ d , da , ad , cd ]
  • c -> [ cd, bc , ec ]

i thought of few things nothing ok :

  1. full text search : cannot modify input db file think cannot use it
  2. one sqlite query (name ?% or name %?%) : not sorted. perhaps query not aware can figured out
  3. two differents queries (name ?% , name %?%) : how implement content provider ? cursorwrapper ? mergecursor ? custom loader ?

i have seen lot of examples nothing useful custom search.

thanks help.

edit : query on d should give [ d , da , ad , cd ].

the custom sort order want is : pattern% , %pattern% (for example socks should come before a pair of socks)

here hack requirements:

select distinct t.name (select *, 1 sec items name 'd%' union select *, 2 sec items name '%d%') t  order t.sec asc 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -