One of the mechanisms may be triangulation using the masts of mobile phones. If you can determine how far you are from two or more famous places, you can calculate your position.
However (and this is big, however), I do not know how you (as a developer) can:
a) access the location of all the mobile phone masts in your area
b) Interview the masts to see which ones they should look for in your database.
I believe that it works aGPS (as TheVillageIdiot mentioned), but it is on the phone that will have access to this information.
source share