You should use sortOrder
- last parameter of CursorLoader's contructor.
Let's assume your table has column named lat
for latitude and lon
for longitude. User's location also described via latitude/longitude userLat
and userLon
. For sorting we aren't need to know precise distance - approximate distance will be enough. For that You can use Pythagorean theorem.
sortOder
will be like this: abs(lat - userLat)* abs(lat - userLat) + abs(lon-userLon)*abs(lon-userLon)
. This computation contains only supported by Sqlite operators.
Note 1: you have to change code above in order to provide correct String where userLat
and userLon
are replaced with their values.
Note 2: you can't use this formula to compute precise distance.