title: Read/Write Files from the Content Provider
body: <p>I want to be able to create a file from the Content Provider, however I get the following error:</p>
  
  <pre><code>java.io.Filenotfoundexception: /0: open file failed: erofs (read-only file system)
  </code></pre>
  
  <p>What I am trying to do is create a file whenever an application calls the insert method from my Provider. This is the excerpt of the code that does the file creation:</p>
  
  <pre><code>FileWriter fstream = new FileWriter(valueKey);
  BufferedWriter out = new BufferedWriter(fstream); 
  out.write(valueContent);
  out.close();
  </code></pre>
  
  <p>Originally I wanted to use openFileOutput() but the function appears to be undefined.</p>
  
  <p>Anyone has a workaround to this problem?</p>
  
  <p><strong>EDIT:</strong> I found out that I had to specify the directory as well. Here is a more complete snippet of the code:</p>
  
  <pre><code>File file = new File("/data/data/Project.Package.Structure/files/"+valueKey);
  file.createNewFile();
  FileWriter fstream = new FileWriter(file);
  BufferedWriter out = new BufferedWriter(fstream);
  out.write(valueContent);
  out.close();    
  </code></pre>
  
  <p>I also enabled the permission</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>This time I got an error saying:</p>
  
  <pre><code>java.io.IOException: open failed: ENOENT (No such file or directory)
  </code></pre>