title: How to create and/or append to a file on android?
body: <p>Here's what I'm doing:</p>
  
  <pre><code>    static void writeToFile(String text) {
      try {
          synchronized (fileLock) {
              File external = Environment.getExternalStorageDirectory();
              String sdcardPath = external.getPath();
              FileWriter filewriter = new FileWriter(sdcardPath
                      + "/Documents/myfile.txt", true);
              BufferedWriter out = new BufferedWriter(filewriter);
  
              out.write(text);
  
              out.close();
              filewriter.close();
          }
      } catch (Exception e) {
          android.util.Log.d("failed to save file", e.toString());
      }
  }
  </code></pre>
  
  <p>On open file I get following exception:</p>
  
  <pre><code>java.io.FileNotFoundException: /mnt/sdcard/Documents/myfile.txt: 
      open failed: ENOENT (No such file or directory)
  </code></pre>
  
  <ol>
  <li>The directory <code>/mnt/sdcard/Documents/</code> exists according to Root Browres</li>
  <li>The application manifest does contain <code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;</code></li>
  <li><code>myfile.txt</code> does not exist, I want it created or appended</li>
  </ol>
  
  <p>How do I create or append to a file on android?</p>
  
  <p><strong>UPDATE</strong>
  Here is my AndroidManifest.xml:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.mytest"
      android:versionCode="1"
      android:versionName="1.0" &gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="15" /&gt;
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/title_activity_main" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>