三星手机获取SD卡路径

/** 
 * 获取内置SD卡路径 
 * @return 
 */  
public String getInnerSDCardPath() {    
    return Environment.getExternalStorageDirectory().getPath();    
}  

/** 
 * 获取外置SD卡路径 
 * @return  返回的集合 要么只有一条记录 要么为空 
 */  
public List<String> getExtSDCardPath()  
{  
    List<String> lResult = new ArrayList<String>();  
    try {  
        Runtime rt = Runtime.getRuntime();  
        Process proc = rt.exec("mount");  
        InputStream is = proc.getInputStream();  
        InputStreamReader isr = new InputStreamReader(is);  
        BufferedReader br = new BufferedReader(isr);  
        String line;  
        while ((line = br.readLine()) != null) {  
            if (line.contains("extSdCard"))  
            {  
                String [] arr = line.split(" ");  
                String path = arr[1];  
                File file = new File(path);  
                if (file.isDirectory())  
                {  
                    lResult.add(path);  
                }  
            }  
        }  
        isr.close();  
    } catch (Exception e) {  
    }  
    return lResult;  
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容