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 :
- full text search : cannot modify input db file think cannot use it
- one sqlite query (
name ?% or name %?%
) : not sorted. perhaps query not aware can figured out - 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
Post a Comment