Android 6.0区别U盘和SD卡设备
Posted 胖子luffy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 6.0区别U盘和SD卡设备相关的知识,希望对你有一定的参考价值。
public static boolean isSdcardExists(Context context)
StorageManager storageManager = StorageManager.from(context.getApplicationContext());
List<VolumeInfo> volumes = storageManager.getVolumes();
for (VolumeInfo volInfo : volumes)
DiskInfo diskInfo = volInfo.getDisk();
if (diskInfo != null && diskInfo.isSd())
String sdcardState = volInfo.getEnvironmentForState(volInfo.getState());
if (Environment.MEDIA_MOUNTED.equals(sdcardState))
return true;
return false;
public static int isudiskExists(Context context)
int num = 0;
StorageManager storageManager = StorageManager.from(context.getApplicationContext());
List<VolumeInfo> volumes = storageManager.getVolumes();
for (VolumeInfo volInfo : volumes)
DiskInfo diskInfo = volInfo.getDisk();
if (diskInfo != null && diskInfo.isUsb())
String sdcardState = volInfo.getEnvironmentForState(volInfo.getState());
if (Environment.MEDIA_MOUNTED.equals(sdcardState))
num++;
return num;
以上是关于Android 6.0区别U盘和SD卡设备的主要内容,如果未能解决你的问题,请参考以下文章
android 6.0 修改vold check sd卡同步改成异步机制
1.Android6.0运行时权限简介_2.Android6.0权限适配之WRITE_EXTERNAL_STORAGE(SD卡写入)3_.Android 6.0 运行时权限理解