中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Android SD卡工具類

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

Android的manifest.xml文檔中聲名權(quán)限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>  
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>

 判斷SDcard是否可以用

    public static boolean isSdCardExists() {  
            if (android.os.Environment.getExternalStorageState().equals(  
                    android.os.Environment.MEDIA_MOUNTED)) {  
                return true;  
            } else {  
                Log.e(" ", "the Sdcard is not exists");  
                return false;  
            }  
        }  

 獲取SD卡總大小

    public static String getSdCardTotalSize() {  
            if (!isSdCardExists())  
                return "";  
            File path = Environment.getExternalStorageDirectory();  
            StatFs stat = new StatFs(path.getPath());  
            long blockSize = stat.getBlockSize();  
            long availableBlocks = stat.getBlockCount();  
            return String.valueOf((availableBlocks * blockSize) / 1024 / 1024);  
        }  

獲取SD卡可用大小

    public static String getSdcardAvailbleSize() {  
           if (!isSdCardExists())  
               return "";  
           File path = Environment.getExternalStorageDirectory();  
           StatFs stat = new StatFs(path.getPath());  
           long blockSize = stat.getBlockSize();  
           long availableBlocks = stat.getAvailableBlocks();  
           return String.valueOf((availableBlocks * blockSize) / 1024 / 1024);  
       }  

 獲取根目錄路徑

    public static String getRootPath() {  
           if (!isSdCardExists())  
               return "";  
           return Environment.getExternalStorageDirectory().getPath();  
       }  

獲取根目錄文件列表

    public static File[] getRootFiles() {  
           if (getRootPath().equals(""))  
               return null;  
           List<File> files = new ArrayList<File>();  
           File file = new File(getRootPath());  
           return file.listRoots();  
       }  

標(biāo)簽: ssd 權(quán)限

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Go語言冒泡排序?qū)崿F(xiàn)代碼

下一篇:Go語言使用Scp傳輸文件