public String hebGetExternalRootDir(String externalAndriodSubDirPath){ if ( externalAndriodSubDirPath.isEmpty()){ File file = getActivity().getExternalFilesDir(null); externalAndriodSubDirPath = file.toString(); file = null; } if (externalAndriodSubDirPath.contains("/Android")) { return externalAndriodSubDirPath.split("/Android")[0]; } return ""; } public File hebCreateFile(String filePath) { int index = filePath.lastIndexOf("/"); if (index>0) { String dir = filePath.substring(0, filePath.lastIndexOf("/")); File dirInfo = new File(dir); if (false == dirInfo.exists()) { Boolean bOK = dirInfo.mkdirs(); if (false == bOK) { dirInfo = null; return null; } } dirInfo = null; } return new File(filePath); } public Boolean hebCreateFile2(String filePath) { File fd = hebCreateFile(filePath); if (null != fd) { fd = null; return true; } return false; }
完。