title: how to send data to server in android
body: <p>I want to send latitude and longitude cyclically in my app.
  This is the function which get this parameters using GPS</p>
  
  <pre><code> private void showLocation(Location location) {
      String latitude = "Latitude: ";
      String longitude = "Longitude: ";
  
      if (location != null) {
          latitude += location.getLatitude();
          longitude += location.getLongitude();
  }
  }
  </code></pre>
  
  <p>I was looking methods in the web, I found some but it didn't work and it's deprecated</p>
  
  <pre><code>public void sendData(double latitude, double longitude){
      HttpClient httpclient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost("http://192.x.x.x:8080/run/mypage.php");
      try {
          List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
  
          nameValuePairs.add(new BasicNameValuePair("Latitude", Double.toString(latitude)));
          nameValuePairs.add(new BasicNameValuePair("Longitude", Double.toString(longitude)));
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          httpclient.execute(httppost);
  
      } catch (ClientProtocolException e) {
          // TODO Auto-generated catch block
      } catch (IOException e) {
          // TODO Auto-generated catch block
      }
  }
  </code></pre>