title: I am getting HttpResponse but responce.getEntity().getContent() shows NullPointerException
body: <pre><code>protected String doInBackground(String... urls) {
      String url = urls[0];
      String result = "";
  
      HttpResponse response = doResponse(url);
  
      if (response == null) {
          return result;
      } else {
  
          try {
              result = inputStreamToString(response.getEntity().getContent());
  
          } catch (IllegalStateException e) {
              Log.e(TAG, e.getLocalizedMessage(), e);
  
          } catch (IOException e) {
              Log.e(TAG, e.getLocalizedMessage(), e);
          }
  
      }
  
      return result;
  }
  </code></pre>
  
  <p>I am going to post data into database here below i attached my remaining codes so please check and clear my problem please</p>
  
  <pre><code>private HttpResponse doResponse(String url) {
  
      HttpClient httpclient = new DefaultHttpClient(getHttpParams());
  
      HttpResponse response = null;
  
      try {
          switch (taskType) {
  
          case POST_TASK:
              HttpPost httppost = new HttpPost(url);
              // Add parameters
              httppost.setEntity(new UrlEncodedFormEntity(params));
              response = httpclient.execute(httppost);
  
              break;
          case GET_TASK:
              HttpGet httpget = new HttpGet(url);
              response = httpclient.execute(httpget);
              break;
          }
      } catch (Exception e) {
  
          Log.e(TAG, e.getLocalizedMessage(), e);
  
      }
  
      return response;
  }
  
  private String inputStreamToString(InputStream is) {
  
      String line = "";
      StringBuilder total = new StringBuilder();
  
      // Wrap a BufferedReader around the InputStream
      BufferedReader rd = new BufferedReader(new InputStreamReader(is));
  
      try {
          // Read response until the end
          while ((line = rd.readLine()) != null) {
              total.append(line);
          }
      } catch (IOException e) {
          Log.e(TAG, e.getLocalizedMessage(), e);
      }
  
      // Return full string
      return total.toString();
  }
  </code></pre>
  
  <p>I am getting <code>NullPointerException</code> at following line,</p>
  
  <p><code>result = inputStreamToString(response.getEntity().getContent());</code>.</p>
  
  <p>I don't understand about entity and content.anyone can help me??</p>