title: Location.distanceTo not giving correct results in android
body: <p>I am trying to calculate the distance between two locations (Current location with the previous location). </p>
  
  <p>So I tried the following: </p>
  
  <pre><code>Location previousLocation = new Location("");
  previousLocation.setLatitude(sharedPreferences.getFloat("previousLatitude", 0f));
  previousLocation.setLongitude(sharedPreferences.getFloat("previousLongitude", 0f));
  float distance = location.distanceTo(previousLocation);
  totalDistanceInMeters += distance;
  editor.putFloat("totalDistanceInMeters", totalDistanceInMeters);
  Log.e("Location Update","totalDistance"+totalDistanceInMeters);     
  if (totalDistanceInMeters &gt; 1)
  {
   Toast.makeText(getApplicationContext(), "Total UpdateLocation"+totalDistanceInMeters/1609, Toast.LENGTH_SHORT).show();
   Log.e("Alert","Update");
  }
  </code></pre>
  
  <p>To test the above code. The first time result was perfect and when it triggered the second time. The phone was in the same location but I am getting distances like 141.0111 m. thrid time 304.0011 m. Am I doing something wrong here?</p>
  
  <p>The results are not showing up correctly. According to doc online the results are in metres.</p>
  
  <p>Is there an easy way to calculate the difference between the first location results with the second one and if it is more than 10m I would like to do some other calculation if not just keep quite.</p>
  
  <p>Let me know.</p>