title: How to open an xml file in an android app
body: <p>I use a dom parser in android in order to parse an XML file.
  Also, i use eclipse.</p>
  
  <p>I do:</p>
  
  <pre><code>File file = new File("myfile.xml");
  if(file!= null)
      Log.d(MainActivity.LOG_TAG,"FILE OK");
  else
      Log.d(MainActivity.LOG_TAG,"FILE NOT OK!!!");
  </code></pre>
  
  <p>After the previous statement i get "<strong>FILE OK</strong>" in LogCat.</p>
  
  <p>Then I would like to parse the "myfile.xml". The system can't find the file specified</p>
  
  <p>My code is as following:</p>
  
  <pre><code>DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
  domFactory.setNamespaceAware(true);
  DocumentBuilder builder = domFactory.newDocumentBuilder();
  
  Document doc = builder.parse(file);
  Log.d(MainActivity.LOG_TAG," Before parsing"); 
  
  if(doc != null)
    Log.d(MainActivity.LOG_TAG," DOC is not null");
  else
    Log.d(MainActivity.LOG_TAG," DOC IS NULL!!!");
  </code></pre>
  
  <p>I get in LogCat:</p>
  
  <pre><code> Before parsing
   W/System.err(2099): java.io.FileNotFoundException: /myfile.xml: open failed: ENOENT (No such file or directory)
  </code></pre>
  
  <p>I noticed that there is a '/' before myfile.xml and I can't understand where is the root
  dir</p>
  
  <p>Can anyone help me?
  Thanks</p>