您的位置:首页 > 移动开发 > Android开发

存储卡路径(接口路径)

2016-04-18 19:11 417 查看
public List Getpaths(){
List<String> paths = new ArrayList<String>();
 StorageManager storageManager =(StorageManager) getSystemService(Context.STORAGE_SERVICE); 

    try { 
        Class<?>[] paramClasses ={}; 

        Method getVolumePathsMethod =StorageManager.class.getMethod("getVolumePaths", paramClasses); 

       getVolumePathsMethod.setAccessible(true); 

        Object[] params = {}; 

        Object invoke =getVolumePathsMethod.invoke(storageManager, params); 

        for (int i = 0; i <((String[])invoke).length; i++) { 

           
  paths.add(((String[])invoke)[i]); 
        } 
    } catch (Exception e1) { 

        e1.printStackTrace(); 

    } 
return paths;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android