(親フォルダを含む)新しいファイルを作成し、外部のSDカードのルートディレクトリへのアクセス

    パブリック文字列hebGetExternalRootDir(文字列externalAndriodSubDirPath){
         場合(externalAndriodSubDirPath.isEmpty()){ 
            ファイルファイル = getActivity()getExternalFilesDir(NULL ); 
            externalAndriodSubDirPath = file.toString()。
            ファイル = nullを
        } 

        であれば(externalAndriodSubDirPath.contains( "/アンドロイド" )){
             リターン externalAndriodSubDirPath.split( "/アンドロイド")[0 ]; 
        } 
        を返します「」
    } 

    パブリックファイルhebCreateFile(文字列filePathに){
        int型のインデックス= filePath.lastIndexOf( "/" );
        もし(指数> 0 ){ 
            文字列DIR = filePath.substring(0、filePath.lastIndexOf( "/" )); 
            ファイルdirInfoは = 新しいファイル(ディレクトリ)を、
            もし == dirInfo.exists()){ 
                ブールBOK = dirInfo.mkdirs()。
                もし == BOK){ 
                    dirInfo = NULL ;
                    リターン ヌル
                }
            }
            dirInfo = nullを
        } 
        を返す 新しいファイル(filePathにします)。
    }

 

仕上がり。

 

おすすめ

転載: www.cnblogs.com/liyou-blog/p/12058307.html
おすすめ