我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

调用Android系统接口获取不到TF卡路径时

private String getExternalStoragePath() {
        String value = "";

        try {
            if (!Environment.isExternalStorageEmulated() && Environment.isExternalStorageRemovable()
                    && Environment.getExternalStorageDirectory().canWrite()) {
                value = Environment.getExternalStorageDirectory().getPath();
            } else {
                final String[] sdPathArray = {"/storage/extSdCard", 
                        "/storage/sdcard1", 
                        "/mnt/sdcard2", 
                        "/mnt/sdcard-ext", 
                        "/mnt/ext_sdcard", 
                        "/mnt/sdcard/SD_CARD", 
                        "/mnt/sdcard/extra_sd", 
                        "/mnt/extrasd_bind", 
                        "/mnt/sdcard/ext_sd", 
                "/mnt/sdcard/external_SD"};
                for (String path : sdPathArray) {
                    File file = new File(path);
                    if (file.isDirectory() && file.canRead() && file.canWrite()) {
                        value = path;
                        break;
                    }
                }
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return value;
    }

当前文章:调用Android系统接口获取不到TF卡路径时
本文来源:http://shouzuofang.com/article/igdiep.html

其他资讯