title: Using UrlConnection instead of HttpClient with JSONArray
body: <p>Now I am using HttpClient which is deprecated! :-(
  So I would like to use HttpUrlConnection..
  Here is my code:</p>
  
  <pre><code>public JSONArray GetDetails(int ID){
  
  
  
          // Get HttpResponse Object from url.
          // Get HttpEntity from Http Response Object
  
          HttpEntity httpEntity = null;
  
          try
          {
  
             DefaultHttpClient httpClient = new DefaultHttpClient();  // Default HttpClient
              HttpGet httpGet = new HttpGet(StaticVariables.url_for_details + ID);
  
              HttpResponse httpResponse = httpClient.execute(httpGet);
  
              httpEntity = httpResponse.getEntity();
  
  
          } catch (ClientProtocolException e) {
  
              // Signals error in http protocol
              e.printStackTrace();
  
              //Log Errors Here
  
  
  
          } catch (IOException e) {
              e.printStackTrace();
          }
  
  
          // Convert HttpEntity into JSON Array
          JSONArray jsonArray = null;
  
          if (httpEntity != null) {
              try {
                  String entityResponse = EntityUtils.toString(httpEntity);
  
                  Log.e("Entity Response  : ", entityResponse);
  
                  jsonArray = new JSONArray(entityResponse);
  
              } catch (JSONException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
  
          return jsonArray;
      }
  </code></pre>
  
  <p>Can someone help me to use HttpUrlConnection instead of the HttpClient so I can use jsonarray furthermore?</p>