开发者

Android: Best practice to get data from SQLite and show in a listview order by distance from phone

I have a SQL Lite database on places with a latitude and longitude and I want to get the data from SQL Lite and some way, either in the SQL question or in a custom adapter or what the best practice is sort out all places that are in a 5 miles distance from the phone location and show in a ListView.

I have one idea I figure out but wounder if someone has a better idea.

I can get out all data from SQL Lite and put it in a ListView w开发者_如何学Cith a custom adapter that gets the phone location from a LocationManager and then somehow remove the items that has a distanceTo longer then 5 miles and I hope with the custom adapter I can sorting also but don't have all pieces here yet.

And I think my solution going to work but is there any better solution?

I can also say that its around 400 places so maybe not a big deal to do this with custom adapter.

All solutions is good, I am relative new on Android but learning.


I think your approach is good considering that the SQLite database has no spatial functionality. Your custom adapter should then be able to limit the data to those within a specified distance from the phone's current location.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜