title: Creating a file on the SD-Card in android
body: <p>I want to create a file on the SD-Card and later save a CSV file in it.</p>
  
  <p>From surfing around I noticed that there seem to be two ways about going about it:</p>
  
  <p><a href="http://developer.android.com/guide/topics/data/data-storage.html#filesExternal" rel="nofollow noreferrer">http://developer.android.com/guide/topics/data/data-storage.html#filesExternal</a></p>
  
  <blockquote>
    <p>If you're using API Level 8 or
    greater, use getExternalFilesDir() to
    open a File that represents the
    external storage directory where you
    should save your files. This method
    takes a type parameter that specifies
    the type of subdirectory you want,
    such as DIRECTORY_MUSIC and
    DIRECTORY_RINGTONES (pass null to
    receive the root of your application's
    file directory). </p>
    
    <p>If you're using API Level 7 or lower,
    use getExternalStorageDirectory(), to
    open a File representing the root of
    the external storage. You should then
    write your data in the following
    directory:</p>
    
    <p>/Android/data//files/</p>
  </blockquote>
  
  <p>And <a href="http://www.anddev.org/working_with_files-t115.html" rel="nofollow noreferrer">http://www.anddev.org/working_with_files-t115.html</a> :</p>
  
  <pre><code>FileWriter f = new FileWriter("/sdcard/download/possible.txt");
  </code></pre>
  
  <p>What way should I use? If the first, how do I write my application to be compatible with both API level &lt;=7 and >=8? Is there some good tutorial for doing it the first way?</p>