Android创建文件夹及时刷新

创建文件及时刷新的代码记录一下


public  File createDir(String path) {
    File file = new File(path);
    if (!file.exists()) {
        file.mkdirs();//mkdirs可以创建多级目录下的文件夹
        MediaScannerConnection.scanFile(context, new String[] { file.getAbsolutePath() }, null, null);
        LogUtil.d(file.getAbsolutePath() + "文件夹创建成功");
    }else{
        LogUtil.d(file.getAbsolutePath() + "文件夹已经存在");
    }
    return file;

}

猜你喜欢

转载自blog.csdn.net/qq_33796069/article/details/104901794