android中创建应用文件夹

本人要在onCreate()方法的第一个activity中创建应用文件夹,但是没创建成。代码如下:

 if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
        File fil = new File(this.getFilesDir().getPath()+File.separator+"MyContactsBackUp");
        fil.mkdirs();

} else {
    File directory = new File(Environment.getExternalStorageDirectory()+File.separator+"MyContactsBackUp");
    directory.mkdirs();
}
File f = new File(android.os.Environment.getExternalStorageDirectory(),File.separator+"MyContactsBackUp/");
f.mkdirs();

如果是内部核心应用:

File f = new File(getCacheDir(),File.separator+"MyContactsBackUp/");
f.mkdirs();

代码:

if (android.os.Environment.getExternalStorageState().equals(
    android.os.Environment.MEDIA_MOUNTED)) {

       File podcastFolder = new File(Environment.getExternalStorageDirectory() + File.separator
                                             + getString(R.string.app_name));
} else {
            /* save the folder in internal memory of phone */

    File podcastFolder = new File("/data/data/" + getPackageName()
                    + File.separator + getString(R.string.app_name));

}

有没有加权限:

<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- 在sdcard中创建/删除文件的权限 -->
<uses-permission
    android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />