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中的商店值
您已經閱讀關於共享偏好的文檔,這也解釋了非常簡單的如何使用它?至少試着去做。 –