How to copy a xml file from res/raw folder to sd card of android?
<p>I want to copy a xml file from res/raw folder to the sd card. This question is actually specific to the ODK Collect. But any help would be appreciated. I have looked at <a href="http://stackoverflow.com/questions/3851712/android-how-to-create-a-directory-on-the-sd-card-and-copy-files-from-res-raw-to">Android: How to create a directory on the SD Card and copy files from /res/raw to it??</a> and other similar posts on the web but I was still unable to copy. Maybe, its because I am working on ODK Collect. 
This is my code for copying the file:</p>

<pre><code>       try {
         InputStream in = getResources().openRawResource(R.raw.problem2);
         OutputStream out = new FileOutputStream(Collect.FORMS_PATH+"/problem2");

                // Transfer bytes from in to out
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) &gt; 0) {
                    out.write(buf, 0, len);
                }
                in.close();
                out.close();

        }           
     catch(IOException e) { }
</code></pre>

<p>Thanks in advance.</p>
