Android 使用gps的SharedReference崩溃

Android 使用gps的SharedReference崩溃,android,gps,sharedpreferences,Android,Gps,Sharedpreferences,我试图使用SharedReferences根据gps位置计算距离,但每当gps改变时,应用程序就会崩溃。有什么建议吗 public void onLocationChanged(Location location) { SharedPreferences prefs = this.getSharedPreferences("com.trekker.client", Context.MODE_APPEND); SharedPreferences.Editor editor = prefs.edit

我试图使用SharedReferences根据gps位置计算距离,但每当gps改变时,应用程序就会崩溃。有什么建议吗

public void onLocationChanged(Location location) {
SharedPreferences prefs = this.getSharedPreferences("com.trekker.client", Context.MODE_APPEND);
SharedPreferences.Editor editor = prefs.edit(); String str = "Latitude: "+location.getLatitude()+"Longitude: "+location.getLongitude();
currentLon1 = location.getLongitude();
currentLat1 = location.getLatitude();
if(i==0){
    editor.putFloat(LATITUDE1,(float)location.getLatitude());
    editor.putFloat(LONGITUDE1, (float) location.getLongitude());
    editor.commit();
    i++;
}
else{
lat1 = (double)prefs.getFloat(LATITUDE1, 0);
lon1 = (double)prefs.getFloat(LONGITUDE1, 0);
 GPS.calculateDistance(lat1,lon1,currentLat1,currentLon1);editor.putFloat(LATITUDE1,(float)location.getLatitude());editor.putFloat(LONGITUDE1, (float) location.getLongitude());
editor.commit;
}

可以共享stacktrace吗?在中国手机上没有stacktrace:\