title: Android 2.1 using 4.4 sdk - How to send data using HTTP POST request?
body: <p>This is my UI layout:<br/><br/>
  <a href="https://i.stack.imgur.com/z5Pmn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z5Pmn.png" alt="enter image description here"></a></p>
  
  <p>I want to send some msg by using HTTP POST request.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          EditText editmsg = (EditText) findViewById(R.id.editMessage);
          EditText editmail = (EditText) findViewById(R.id.editMail);
          Button btnsubmit = (Button) findViewById(R.id.btnSubmit);
          btnsubmit.setOnClickListener((View.OnClickListener) this);
  
          URL url;
          HttpURLConnection urlConnection = null;
          try {
              url = new URL("http://www.yoursite.com/script.php");
  
              urlConnection = (HttpURLConnection) url.openConnection();
              urlConnection.setRequestMethod("POST");
              urlConnection.setDoOutput(true);
  
              InputStream in = urlConnection.getInputStream();
  
              InputStreamReader isw = new InputStreamReader(in);
  
              int data = isw.read();
              while (data != -1) {
                  char current = (char) data;
                  data = isw.read();
                  System.out.print(current);
              }
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              if (urlConnection != null) {
                  urlConnection.disconnect();
              }
          }
      }
  }
  </code></pre>
  
  <p>I came to know that httpclient is not supported to higher sdk version. So please, help me how to write code for http request post to send some msg and email with given url.</p>