title: Copy xml from raw folder to internal storage and use it in android
body: <p>I have server.xml inside my raw folder and I want to copy this to my internal storage in the first run of the app. </p>
  
  <p>Then, my app will write to server.xml once in awhile after each run. </p>
  
  <p>to copy server.xml to internal storage my code is : </p>
  
  <p>if ("server.xml") not exists:</p>
  
  <pre><code>File file = new File("server.xml");
      try {
          Context context = getApplicationContext();
          InputStream inputStream =    context.getResources().openRawResource(R.raw.server);
          FileOutputStream fileOutputStream = new FileOutputStream(file);
  
          byte buf[]=new byte[1024];
          int len;
          while((len=inputStream.read(buf))&gt;0) {
              fileOutputStream.write(buf,0,len);
          }
  
          fileOutputStream.close();
          inputStream.close();
      } catch (IOException e1) {}
  </code></pre>
  
  <p>now to add to the server.xml </p>
  
  <pre><code>documentBuilder = documentBuilderFactory.newDocumentBuilder();       
  Document document = documentBuilder.parse("server.xml");
  Element root = document.getDocumentElement();
  </code></pre>
  
  <p>but it gives me IOExeption of 
  java.net.MalformedURLException: Protocol not found: server.xml</p>
  
  <p>I really appreciate any help. I am very new to android and trying hard get my head around it. </p>