Android: Custom collation in SQLite

a 夏天 提交于 2019-12-24 01:54:40

问题


Is there a way of getting SQLite on Android to use a custom collation routine?

I'm aware of SQLite's C interface to do this, so I guess I could do it by writing C code for building with the NDK, but I'd really prefer a way to do it at a higher level.

I need to arrange things so that the text B-9 is sorted before B-29, for example. The default alphabetical sort gets them the wrong way round.


回答1:


I am pretty sure that there is no way to do this in Android.

My suggestion would be to have a custom column used for ordering where you insert the value in a modified way that gets sorted as you wish.

In your case you could insert B-9 as B-09 or B-00....09 depending on the max value.



来源:https://stackoverflow.com/questions/8128834/android-custom-collation-in-sqlite

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