how to I compare and retrieve them?
There are i guess more possible approaches. You could do it with well-designed WHERE
clause but performance won't be good i think.
So i recommend you to fetch all rows into Cursor
. Then loop through Cursor and compare each row's latitude and longitude with your currect location. Row that is in desired distance save into some helper structure for example into dynamic array (List for instance).
For calculate distance between two points you can use Euclidean distance. For converting degrees to decimal have look at this article.
Hope it helps you and made thing clearer.