public static GPLocationProvider getMyLocation() { if (myLocation == null) { myLocation = new GPLocationProvider(); bool bSucc = false; string possibleFile = GPFileHelper.getAppDataFile("mylocation.xml"); if (File.Exists(possibleFile)) { try { myLocation.loadXml(possibleFile); bSucc = true; } catch { } } if (bSucc == false) { NumberFormatInfo fmt = new NumberFormatInfo(); GPLocation loc = new GPLocation(); loc.setCity(GPUserDefaults.StringForKey("myloc.city", "Mayapur")); loc.setCountryCode(GPUserDefaults.StringForKey("myloc.country", "IN")); loc.setLatitudeNorthPositive(double.Parse(GPUserDefaults.StringForKey("myloc.lat", "23.423413"), fmt)); loc.setLongitudeEastPositive(double.Parse(GPUserDefaults.StringForKey("myloc.lon", "88.388079"), fmt)); loc.setTimeZoneName(GPUserDefaults.StringForKey("myloc.tzname", "Asia/Calcutta")); myLocation.setDefaultLocation(loc); } } return(myLocation); }
public static void saveMyLocation() { string possibleFile = GPFileHelper.getAppDataFile("mylocation.xml"); try { if (myLocation != null) { myLocation.saveXml(possibleFile); } } catch { } }