How to programmatically load an HTML page in android and get its HTML?

I need to load an HTML page programmatically and then get its Html. I mainly deal with page loading. If I load a page, where will I put it? Should I store a String variable? If so, how?

Please help me.

+7
source share
2 answers

This site gives a good explanation of how to download the file, as well as how to set the place where it should be stored. You do not need and should not store it in a string variable. If you want to manipulate data, I suggest you use an XML parser .

+8
source

You can call this method in doInBackground AsyncTask

String html = ""; String url = "ENTER URL TO DOWNLOAD"; HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder str = new StringBuilder(); String line = null; while((line = reader.readLine()) != null) { str.append(line); } in.close(); html = str.toString(); 
0
source

All Articles