I get Parent directory of file is not writable for an SDCard export
<p>I have this code:</p>

<pre><code>public static class ExportDatabaseFileTask extends AsyncTask&lt;String, Void, Boolean&gt; {
    private Context ctx;

    /**
     *
     */
    public ExportDatabaseFileTask(Context ctx) {
        super();
        this.ctx = ctx;
    }

    // automatically done on worker thread (separate from UI thread)
    protected Boolean doInBackground(final String... args) {

        File dbFile = new File(Environment.getDataDirectory()
                + "/data/com.mypkg/databases/log.db");

        File exportDir = new File(Environment.getExternalStorageDirectory(), "");
        if (!exportDir.exists()) {
            exportDir.mkdirs();
        }
        File file = new File(exportDir, dbFile.getName());

        try {
            file.createNewFile();//*
            this.copyFile(dbFile, file);
            return true;
        } catch (IOException e) {
            Log.e("mytag", e.getMessage(), e);
            return false;
        }
    }

    // can use UI thread here
    protected void onPostExecute(final Boolean success) {
        if (success) {
            Toast.makeText(ctx, "Export successful!", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(ctx, "Export failed", Toast.LENGTH_SHORT).show();
        }
    }

    void copyFile(File src, File dst) throws IOException {
        FileChannel inChannel = new FileInputStream(src).getChannel();
        FileChannel outChannel = new FileOutputStream(dst).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } finally {
            if (inChannel != null)
                inChannel.close();
            if (outChannel != null)
                outChannel.close();
        }
    }

}
</code></pre>

<p>On the marked line of</p>

<pre><code>file.createNewFile();
</code></pre>

<p>I get <code>java.io.IOException: Parent directory of file is not writable: /sdcard/log.db</code></p>

<p>I have an sdcard installed and I can easily copy files to it. What might be wrong?</p>
