I\'m new to Android and I want to get the whole text from a web page to a string. I found a lot of questions like this but as I said I\'m new to Android and I don\'t know ho
Seeing as you aren't interested in Viewing the content at all, try using the following:
In order to get your source code from an URL you can use this :
HttpClient httpclient = new DefaultHttpClient(); // Create HTTP Client
HttpGet httpget = new HttpGet("http://yoururl.com"); // Set the action you want to do
HttpResponse response = httpclient.execute(httpget); // Executeit
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent(); // Create an InputStream with the response
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) // Read line by line
sb.append(line + "\n");
String resString = sb.toString(); // Result is here
is.close(); // Close the stream
Make sure you run this off the main UI thread in an AsyncTask or in a Thread.