Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android UsbManager: Retrieve USB drive name

Tags:

android

usb

I need the drive name of Pendrive like highlighted in the below image:

enter image description here

I tried UsbDevice.getDeviceName(), UsbDevice.getProductName() & UsbDevice.getManufacturerName() but none of them giving the drive name.

like image 425
Sanif SS Avatar asked Jun 08 '26 20:06

Sanif SS


1 Answers

Finally, I found the solution. use 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 is having the drive name.

like image 109
Sanif SS Avatar answered Jun 11 '26 21:06

Sanif SS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!