title: android, reading values from xml file from SD Card
body: <p>helo, i want to read values from this file: <a href="http://www.nbp.pl/kursy/xml/lastC.xml" rel="nofollow">http://www.nbp.pl/kursy/xml/lastC.xml</a> and fill grid with them. My application download this file and save it on SDCard earch time it`s running. My problem is that my code read empty values. here it is: </p>
  
  <pre><code> @Override
   protected void onCreate(Bundle savedInstanceState) {
  
   super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
       grid= (GridView)findViewById(R.id.grid);
  
      try{    
             url = new URL("http://www.nbp.pl/kursy/xml/LastC.xml");
  
              HttpURLConnection    connection = (HttpURLConnection)url.openConnection();
  
              connection.setRequestMethod("GET");
  
  
              connection.setDoOutput(true);
              connection.connect();
  
  
  
             File dir = new File (android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/Kursy Walut");
                 if(dir.exists()==false) 
                      dir.mkdirs();
  
              File file = new File(dir, "kursywalut.xml");
  
         FileOutputStream fileoutput = new FileOutputStream(file);
  
           InputStream  inputstream = connection.getInputStream();
  
              int tempSize=0;
  
  
              byte[] buffer = new byte[1024];
  
              while((tempSize = inputstream.read(buffer))&gt;0)
              {
  
                  fileoutput.write(buffer, 0, tempSize);
  
              }
  
   fileoutput.close();
  </code></pre>
  
  <p>saved file on my sdCard and make a Toast with info </p>
  
  <pre><code>    Toast.makeText(MainActivity.this, "pobrano do Kursy Walut/kursywalut.xml!!", Toast.LENGTH_SHORT).show();
  
      //here i have a array of string witch i will parse into my grid
  
      String[] items=new String[13];
  
       InputStream in = new FileInputStream(file.getPath());
  
       DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  
    Document doc = builder.parse(in);
    NodeList words = doc.getElementsByTagName("pozycja");
  
    for(int i=0; i&lt;words.getLength(); i++)
    {
        items[i]= ((Element)words.item(i)).getAttribute("kod_waluty");
  
    }
  
    //i setText on some textView to check that i read xmlfile correctly. 
  
     text.setText("value: "+items[5]);
        in.close();
  
  
  
        grid.setAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, items));
  }
  catch(Throwable t){Toast.makeText(this, t.toString(), Toast.LENGTH_LONG).show();}
  
  
  }
  </code></pre>
  
  <p>after this code  my TextView text is only  "value:" without value from xml
     and my grid is empty. I assume that i`m making mistake while reading xml file.
  If anyone could look at this and help me solve it i will by very happy. </p>