SoFunction
Updated on 2025-03-09

Detailed explanation of how to distinguish USB drive and SD card devices in Android 6.0

As shown below:

public static boolean isSdcardExists(Context context) {

  StorageManager storageManager = (());
  List<VolumeInfo> volumes = ();
  for (VolumeInfo volInfo : volumes) {
   DiskInfo diskInfo = ();
   if (diskInfo != null && ()) {
    String sdcardState = (());
    if (Environment.MEDIA_MOUNTED.equals(sdcardState)) {
     return true;
    }
   }

  }
  return false;
 }
public static int isudiskExists(Context context) {
  int num = 0;
  StorageManager storageManager = (());
  List<VolumeInfo> volumes = ();
  for (VolumeInfo volInfo : volumes) {
   DiskInfo diskInfo = ();
   if (diskInfo != null && ()) {
    String sdcardState = (());
    if (Environment.MEDIA_MOUNTED.equals(sdcardState)) {
     num++;
    }
   }

  }
  return num;
 }

The above detailed explanation of the above method of distinguishing between USB flash drive and SD card devices in Android 6.0 is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.