简体   繁体   中英

How to differentiate between sdcard and usb mount in android programatically

I am using the following code for getting the external storage mounted in android device.

 val storageManager = CHSSystemApplication.instance.getSystemService(Context.STORAGE_SERVICE) as StorageManager?
        storageManager?.storageVolumes

I mount the sd card and USB it returns the two storage volume. Is there any way we can differentiate between sd card volume and USB.

to get internal SD card

val internalStorage = System.getenv("EXTERNAL_STORAGE")
val f_exts = File(internalStorage )

To get external SD card

val externalStorage = System.getenv("SECONDARY_STORAGE")
val f_secs = File(externalStorage )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM