我需要像下图中突出显示的那样的驱动器名称:

我试过UsbDevice.getDeviceName()、UsbDevice.getProductName()和UsbDevice.getManufacturerName(),但都没有给出驱动器名称。
发布于 2019-05-15 23:18:44
最后,我找到了解决方案。使用StorageManager。
StorageManager storage = (StorageManager) getSystemService(STORAGE_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
List<StorageVolume> volumes = storage.getStorageVolumes();
for (StorageVolume volume :volumes) {
Log.d("STORAGE", "Device name:" + volume.getDescription(this));
}
}StorageVolume.getDescription具有驱动器名称。
https://stackoverflow.com/questions/54348807
复制相似问题