In all versions, i am able to get SdCard details like serial no., CID number .. except Nougot version.
I am using the below methods to get the SdCard details. Both are working fine all versions except Nougat. Those paths are returning null in nougat version
public void getCID() {
File input = new File("/sys/class/mmc_host/mmc1");
String cidDirectory = null;
File[] sid = input.listFiles();
for (int i = 0; i < sid.length; i++) {
if (sid[i].toString().contains("mmc1:")) {
cidDirectory = sid[i].toString();
String SID = (String) sid[i].toString().subSequence(cidDirectory.length() - 4, cidDirectory.length());
}
}
try {
BufferedReader CID = new BufferedReader(new FileReader(cidDirectory + "/cid"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
String getSDCARDiD() {
try {
File file = new File("/sys/block/mmcblk1");
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();
} catch (IOException e) {
e.printStackTrace();
}
return sd_cid;
}
- Why it is giving null i didn't understand.
- Thanks in advance