Sort results from an Android sdk Cursor's managedQuery in a case insensitive manner

て烟熏妆下的殇ゞ 提交于 2019-12-24 22:14:57

问题


I'm using the string 'MediaStore.Audio.Media.TITLE + " ASC"' to sort the resultant list of a managedQuery in an Android Cursor but, unfortunately, my items that begin with 'a' appear after the items that begin with 'Z'... I would like to know how to perform a managedQuery with the resultant list sorted in a case-insensitive fashion. Help?


回答1:


A quick google search turns up this post which almost directly answers your question. But since I'm assuming you'll want to retain the case of the strings for when you actually need to access the file, you can just use the COLLATE command when your selecting. You'll want a query that looks like this:

select file_name_column from table_name where file_name_column like "%.mp3" or file_name_column like "%.wav" ORDER BY file_name_column COLLATE NOCASE ASC;


来源:https://stackoverflow.com/questions/7934285/sort-results-from-an-android-sdk-cursors-managedquery-in-a-case-insensitive-man

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!