文件

来源:互联网 发布:精雕软件学习 编辑:程序博客网 时间:2024/04/26 17:19
        String[] path = edit_path.split("/");
        File root = null;
        if(path[1].contains("external_sdcard")){
            root = Environment.getExternalStorageDirectory_ext();
        }else{
            root = Environment.getExternalStorageDirectory();
        }
        File downloadDir = null;
        for(int i = 2; i<path.length; i++){
            if(i==2){
                downloadDir = new File(root, path[2]);
                if (!downloadDir.isDirectory() && !downloadDir.mkdirs()) {
                    Log.e(LOGTAG, "download aborted - can't create picturesDir directory "
                            + downloadDir.getPath());
                   }
            }else{
                downloadDir = new File(downloadDir, path[i]);
                if (!downloadDir.isDirectory() && !downloadDir.mkdirs()) {
                    Log.e(LOGTAG, "download aborted - can't create picturesDir directory "
                            + downloadDir.getPath());
                   }
            }
        }
        return downloadDir;
原创粉丝点击