title: How to send a name value pair Object or content values object using post in android api 23 using HttpUrl connection?
body: <p>//Here is what i have tried.
  // I don't know how to append inputurl and Content values and send this to server using HttpURLConnection.</p>
  
  <p>public  JSONObject getJsonFromUrl(String inputurl, ContentValues values) {</p>
  
  <pre><code>    // Making http Request
  
      try {
          URL url=new URL(inputurl);
  
          HttpURLConnection connection=(HttpURLConnection)url.openConnection();
          connection.setReadTimeout(10000 /* milliseconds */);
          connection.setConnectTimeout(15000 /* milliseconds */);
          connection.setRequestMethod("POST");
  
          connection.setDoInput(true);
  
          connection.setDoOutput(true);
  </code></pre>
  
  <p>/// please insert the code here for appending values with url.
              connection.connect();</p>
  
  <pre><code>        //
          inputStream=connection.getInputStream();
  
      }
      catch (java.net.MalformedURLException e1){
          e1.printStackTrace();
      }
      catch (UnsupportedEncodingException e2) {
          e2.printStackTrace();
      }
  
  
      try {
          BufferedReader reader=new BufferedReader(new    InputStreamReader(inputStream,"iso-8859-1"),8);
          reader.read(getPost)
          StringBuilder builder=new StringBuilder();
          String line=null;
  
          while ((line=reader.readLine() !=null){
              builder.append(line + "n");
          }
  
          inputStream.close();
          jsonString=inputStream.toString();
          Log.e("JSON", jsonString);
      }
      catch (Exception e){
          Log.e("Buffer Error", "Error converting result " + e.toString());
      }
  
      // try to parse the string into json object
      try {
          jsonObject=new JSONObject(jsonString);
  
      }
      catch (JSONException e){
          Log.e("JSON Parser", "Error parsing data " + e.toString());
      }
  
      return jsonObject;
  
  }
  </code></pre>
  
  <p>}</p>