Please I want a very simple way to read the content of my php page from my android app! I don't want jSon or something, all I want is to have the content of the php page a String in java! Thank youu in advance!
1 Answer
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
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();
Log.i('HtmlContent',+html)
-
I tried the same code and it wasn't running but now I figured why, it's because of internet permissions in the manifest xml, thank you anyway!– Rida AliAug 17, 2013 at 7:44