[Mtk][M0] 判断SD卡是否存在

2016-05-10  本文已影响151人  灰灰手记

适用平台:MTK
适用版本:M

    public boolean haveExternelSD(Context context) {
        StorageManager mStorageManager = (StorageManager)context.getSystemService(Context.STORAGE_SERVICE);
        String[] mPathList = mStorageManager.getVolumePaths();
        int size = 0;
        for (int i = 0; i < mPathList.length; i++) {
            if ("mounted".equals(mStorageManager.getVolumeState(mPathList[i]))) {
                size++;
            }
        }
        return size == 1 ? false : true;
    }
上一篇下一篇

猜你喜欢

热点阅读