title: java.io.FileNotFoundException: open failed: EROFS (Read-only file system)
body: <p>I have this code that generates an XML file and saves to an external directory.</p>
  
  <pre><code>    try //database structure
      {
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
          //test report elements, does not reflect the real database in the future
          //mandatory/ username, location, caption, media, time(Actually, it's best if the server determines recieve time)
          //optional/
          //reportdata elements
          Document doc = docBuilder.newDocument();
          Element rootElement = doc.createElement("reportdata");
          doc.appendChild(rootElement);
  
          //username elements
          Element username = doc.createElement("username");
          username.appendChild(doc.createTextNode("testusername"));
          rootElement.appendChild(username);
  
          //Location ELEMENTS
          //latitude elements
          Element lat = doc.createElement("latitude");
          lat.appendChild(doc.createTextNode(String.valueOf(latitude)));
          rootElement.appendChild(lat);
          //longitude
          Element longi = doc.createElement("longitude");
          longi.appendChild(doc.createTextNode(String.valueOf(longitude)));
          rootElement.appendChild(longi);
  
          //caption text elements
  
          Element capt = doc.createElement("caption");
          capt.appendChild(doc.createTextNode(captionText.getText().toString()));
          rootElement.appendChild(capt);
  
          //tag elements
          String[] tagArr = new String[selectItems.size()];
          tagArr = selectItems.toArray(tagArr);
          Element tags = doc.createElement("tags");
          rootElement.appendChild(tags);
          int o = selectItems.size();
          for(String s: tagArr) {
              Element tagname = doc.createElement("tagname");
              tagname.appendChild(doc.createTextNode(s));
              tags.appendChild(tagname);
          }
  
          TransformerFactory transformerFactory = TransformerFactory.newInstance();
          Transformer transformer = transformerFactory.newTransformer();
          DOMSource source = new DOMSource(doc);
          //StreamResult result = new StreamResult(System.out);
          StreamResult result = new StreamResult(new File(android.os.Environment.getRootDirectory(), "upload_data.xml"));
          transformer.transform(source, result);
          Log.d("MESSAGE", result.toString());
  </code></pre>
  
  <p>After the creation of the XML file, this exception was raised </p>
  
  <pre><code>D/XML TransformerException﹕ java.io.FileNotFoundException: /system/upload_data.xml: open failed: EROFS (Read-only file system)
  </code></pre>
  
  <p>Any way to fix this?</p>