title: Android - HTTP GET Request huge size of JSON response
body: <p>I have a big JSON input (<a href="http://leteckaposta.cz/828586456" rel="nofollow">download the file</a>) API and I don´t know how to parse this data. I need:</p>
  
  <ol>
  <li>Save this data (entire JSON input) to text file or database. What is the best way for this? </li>
  <li>Load this data from text file or database and create JSONArray from JSON tag "list" (first tag)</li>
  </ol>
  
  <p>The solution should be fast and support Android 2.3. What you have recomend for this? Any ideas?</p>
  
  <p>My code:</p>
  
  <pre><code>        HttpClient httpClient = new DefaultHttpClient();
  
          HttpGet httpGet = new HttpGet(urls[0]);
  
          HttpResponse httpResponse;
  
          httpResponse = httpClient.execute(httpGet);
  
          HttpEntity httpEntity = httpResponse.getEntity();
  
              ... and what next ?...
  </code></pre>
  
  <p>FYI:</p>
  
  <p>EntityUtils throws <code>OutOfMemoryException</code></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I try to save data to file like this: </p>
  
  <pre><code>            InputStream inputStream = httpEntity.getContent();
  
              FileOutputStream output = new FileOutputStream(Globals.fileNews);
              int bufferSize = 1024;
              byte[] buffer = new byte[bufferSize];
              int len = 0;
  
              while ((len = inputStream.read(buffer)) != -1) {
                  output.write(buffer, 0, len);
              }
  </code></pre>
  
  <p>And it´s OK. I load data:</p>
  
  <pre><code>            FileInputStream fis = null;
              StringBuffer fileContent = new StringBuffer("");
  
              fis = new FileInputStream(Globals.fileNews);
  
              byte[] buffer = new byte[1024];
  
              while (fis.read(buffer) != -1) {
                  fileContent.append(new String(buffer));
              }
  </code></pre>
  
  <p>But how convert <code>StringBuffer</code> to <code>JSONObject</code>? <code>fileContent.ToString()</code> is not ideal, sometimes I get <code>OutOfMemoryException</code>.</p>