public class GetCurrentLocation {
String address;
public String GetLocation(Context context) {
StrictMode.ThreadPolicy policy =
new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
GPSService mGPSService = new GPSService(context);
mGPSService.getLocation();
if (mGPSService.isLocationAvailable == false) {
} else {
// Getting location co-ordinates
double latitude = mGPSService.getLatitude();
double longitude = mGPSService.getLongitude();
address=String.valueOf(latitude+""+longitude);
System.out.print(String.valueOf(latitude));
System.out.print(String.valueOf(longitude));
//address = mGPSService.getLocationAddress();
}
return address;
}
}
如何在SharedPreferences中存储值?这些值是经度和纬度。那么我想要在片段中检索它们,有什么想法?SharedPreferences中的商店值
您已经阅读关于共享偏好的文档,这也解释了非常简单的如何使用它?至少试着去做。 –