剛使用JAVA或者寫Android都會傻傻分不清mkdir()和mkdirs()有什麼分别。
其實很簡單mkdir()隻能在下一級目錄裡建立檔案夾,不能帶多級路徑。
原文:Creates the directory named by the trailing filename of this file. Does not create the complete path required to create this directory.
而mkdirs()則不需要在上級檔案夾,直接通過路徑來進行建立。
原文:Creates the directory named by the trailing filename of this file, including the complete directory path required to create this directory.
在使用mkdir()時可以配合getFilesDir()來使用,如果知道完整路徑,還是直接使用mkdirs()比較好。