Skip to content

Instantly share code, notes, and snippets.

@meadhikari
Created September 6, 2012 09:17
Show Gist options
  • Save meadhikari/3653543 to your computer and use it in GitHub Desktop.
Save meadhikari/3653543 to your computer and use it in GitHub Desktop.
Android Out of Memory, How to Optimize
StringBuilder response = new StringBuilder();
String jsonString;
URL url;
HttpURLConnection httpconn;
try {
url = new URL("http://backend-newsinamap.appspot.com");
httpconn = (HttpURLConnection) url.openConnection();
if (httpconn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
BufferedReader input = new BufferedReader(new InputStreamReader(httpconn.getInputStream()),8192);
String strLine = null;
while ((strLine = input.readLine()) != null)
{
response.append(strLine);
}
input.close();
jsonString = response.toString();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment