大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

调用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卡路径时
URL地址:http://dzwzjz.com/article/igdiep.html
在线咨询
服务热线
服务热线:028-86922220
TOP