Sadly, it appears you cannot.
I was looking at something like this for calculating distance from within a sqlite query - it was sometimes mentioned as a method for doing this.
sqlite does support something like this, so documentation and other references will suggest that this is possible. However, after looking at various sources, I came to the conclusion that, while you can do it in several places that use sqlite (like iPhone I believe), you can't do it in Android's sqlite (at least I didn't find anyone able to do this way in Android).
Here are a couple of links that I had found suggesting it wasn't possible in Android and unfortunately I couldn't find any counterexamples. But I'd love to find I'm wrong about this ...
Android sqlite sort on calculated column (co-ordinates distance)
- "The technique you describe does not seem to be applicable to Android, which cannot use sqlite3_create_function(). – CommonsWare Jan 9 '10 at 19:00"
Sqlite on Android: How to create a sqlite dist db function - to be used in the app for distance calculation using lat, long
- org.sqlite is not an Android API, so that is not relevant. – hackbod Mar 1 '10 at 4:59
1
- You are correct, org.sqlite is not an Android API. However, you can use it to implement a Content Provider that does what he asked. – Joshua Smith Mar 1 '10 at 12:39
- Actually, I'm rather skeptical on the approach outlined in the content provider answer you link to. org.sqlite is not in Android, and it is unclear if there exists an org.sqlite implementation that will work in concert with Android's SQLite environment. – Pentium10 Jun 27 '10 at 9:12