调用Android系统接口获取不到TF卡路径时-成都快上网建站

调用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://kswjz.com/article/igdiep.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流