How can I retrieve an SD card's serial number in Android 7.0+?
In Android N access to /sys nad /proc was significantly restricted, this was done to provide stricter sandboxes where applications run. This is explained in https://issuetracker.google.com/issues/37091475 as intentional. Actually its not said that all the data in /sys is not accessible, and Google is open to allow access to other files from this location:
If there are specific files in /sys you believe should be available to applications, but are not, please file a new bug where the request can be evaluated. For instance, /sys/devices/system/cpu is available to all processes, so it's inaccurate to say all of /sys is restricted.
I have a bad feeling that google is making changes similar to Apple where it is not allowed to gain hardware id-s. If that is not resolved then the solution is to use google account IDs instead. But I am aware it is not always possible, and will require major changes in business logic (licensing etc.).
Hopefully your bug report will be considered positively.
another related SO I found : File system changes in Android Nougat
Use StorageVolume.getUuid() on StorageVolume which you get from StorageManager.
The value is volume ID assigned during formatting of the card, and its length/format differs depending on file system type. For FAT32 it is XXXX-XXXX, for NTFS it's longer hex string, for Internal mass storage it returns null.
public String getSDCARDiD(){ String sd_cid = null; try { File file = new File("/sys/block/mmcblk1"); String memBlk; if (file.exists() && file.isDirectory()) { memBlk = "mmcblk1"; } else { //System.out.println("not a directory"); memBlk = "mmcblk0"; } Process cmd = Runtime.getRuntime().exec("cat /sys/block/"+memBlk+"/device/cid"); BufferedReader br = new BufferedReader(new InputStreamReader(cmd.getInputStream())); sd_cid = br.readLine(); //System.out.println(sd_cid); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return sd_cid;}
try this: reference original link :Android get id of SD Card programmatically