Downloading and displaying file doesn't work

  • Replies:1
Dominik Thalhammer
  • Forum posts: 1

Feb 10, 2012, 5:35:52 PM via Website

Hello,
I'm new to Android and wanted to write an Application that retrives an XML file and displays it.
But the Problem is at Downloading
I've tried with this code but it does not work in Simulator.
1URL url = new URL("http://192.168.20.42/temp/filelist.xml");
2 urlConnection = (HttpURLConnection) url.openConnection();
3 //InputStream in = new BufferedInputStream(urlConnection.getInputStream());
4 BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
5
6 StringBuilder total = new StringBuilder();
7 String line;
8 while ((line = r.readLine()) != null) {
9 total.append(line);
10 }
11 EditText text = (EditText) findViewById(R.id.editText1);
12 text.setText(total);
13 }catch(IOException e)
14 {
15
16 }
17 finally {
18 urlConnection.disconnect();
19 }
I have no Idea why. Could you tell me why ?
The Code compiles fine, but if I press the Button to start, nothing happens.

EDIT:
Found the Problem, I forgot to set the permissions correctly

— modified on Feb 10, 2012, 7:37:16 PM

Reply
Eric McBride
  • Forum posts: 1,790

Feb 10, 2012, 8:22:34 PM via App

Glad you got it sorted out!!!

Reply