We are building an Android App that will use user's current location (lat, long) and show top 50 venues around the current location, sorted by distance.
We have these venues stored in an SQLite DB. We plan to ship with the sqlite DB with the app.
In order to fetch only the relevant top 50 closest venues, we want to define a db function DIST (to calculate distance between two points) and use it in our query.
How can I define a custom SQLite function for Android Apps? What will be the Java API call to do this?
We have successfully implemented this approach in our iPhone App - using Objective C.
Update: The answer is that you can not do this.
from: Android. Is it possible to write custom function on C/C++ and use it in SQL query?
A workaround might be to fetch all records where one of the values (say, longitude) is close to the current location. If you use this column as an index then fetching these will be very fast.
Then, you have a much reduced subset to iterate over comparing the latitudes and doing your full distance calculations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With