安卓6.0如何获取外置sd卡路径

 时间:2024-10-13 02:37:04

1、直接使用如下方法即可:

2、privatestaticStri艘绒庳焰nggetStoragePath(ContextmContext,booleanis_rem泠贾高框ovale){StorageManagermStorageManager=(StorageManager)mContext.getSystemService(Context.STORAGE_SERVICE);Class<?>storageVolumeClazz=null;try{storageVolumeClazz=Class.forName("android.os.storage.StorageVolume");MethodgetVolumeList=mStorageManager.getClass().getMethod("getVolumeList");MethodgetPath=storageVolumeClazz.getMethod("getPath");MethodisRemovable=storageVolumeClazz.getMethod("isRemovable");Objectresult=getVolumeList.invoke(mStorageManager);finalintlength=Array.getLength(result);for(inti=0;i<length;i++){ObjectstorageVolumeElement=Array.get(result,i);Stringpath=(String)getPath.invoke(storageVolumeElement);booleanremovable=(Boolean)isRemovable.invoke(storageVolumeElement);if(is_removale==removable){returnpath;}}}catch(ClassNotFoundExceptione){e.printStackTrace();}catch(InvocationTargetExceptione){e.printStackTrace();}catch(NoSuchMethodExceptione){e.printStackTrace();}catch(IllegalAccessExceptione){e.printStackTrace();}returnnull;}

3、好啦,以上就是安卓6.0获取外置sd卡路径的方法,赶快去试试吧!

  • 忍者必须死3海滨·苍牙皮肤效果预览
  • 魔族2人刷黑脚boss攻略
  • 华为P9通过“HiSuite”将旧手机资料导入新手机
  • Wear OS怎么同步日历活动数据
  • QQ音乐智能曲谱怎么使用
  • 热门搜索
    神话故事手抄报 古诗手抄报版面设计 快乐暑假手抄报内容 庆国庆手抄报内容 四年级读书手抄报 我运动我健康手抄报 趣味数学手抄报 手抄报边框大全 手抄报怎么画 关于元旦的英语手抄报