Android 创建文件夹目录

在根目录创建一个名为”mypath”的文件夹。

// 定义文件夹目录地址
final String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mypath";

    /**
     * 创建文件目录
     */
    private void createFileCatalogue() {
        File destDir = new File(txtPath);
        if (!destDir.exists()) {
            destDir.mkdirs();
        }
    }

记得要加上权限:

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

猜你喜欢

转载自blog.csdn.net/mvpstevenlin/article/details/55657509