How can I programatically read the SD Card's CID register, which contains a Serial Number and other information? Can I do it through Android Java, or Native code?
Thanks in advance, Eric
SD hardware IDsv(2) is a two-digit hexadecimal ID assigned by the SD Card Association (SDA) that identifies the card's manufacturer. o(4) is a four-digit hexadecimal ID, also assigned by the SDA, that identifies the card's original equipment manufacturer (OEM) and/or the card contents.
On Windows. Insert the SD card into your computer's card reader. If your computer doesn't have a card reader, you can purchase an external adapter that connects via USB. MicroSD cards will likely need to be inserted into an SD card adapter to fit into most conventional SD card slots.
There are four classes: 2, 4, 6 and 10. The number represents the minimum sustained megabytes per second (MB/s) write speed — the higher the number, the faster the sustained speed.
Insert the SD card and use the command cat sys/block/mmcblk0/device/cid to view the CID (might also be mmcblk1 or higher, depending on your system). Windows users might, for example, use the SD Card Toolbox or other 3rd party software.
Here is sample code for getting SID and CID
if (isExteranlStorageAvailable()) {
try {
File input = new File("/sys/class/mmc_host/mmc1");
String cid_directory = null;
int i = 0;
File[] sid = input.listFiles();
for (i = 0; i < sid.length; i++) {
if (sid[i].toString().contains("mmc1:")) {
cid_directory = sid[i].toString();
String SID = (String) sid[i].toString().subSequence(
cid_directory.length() - 4,
cid_directory.length());
Log.d(TAG, " SID of MMC = " + SID);
break;
}
}
BufferedReader CID = new BufferedReader(new FileReader(
cid_directory + "/cid"));
String sd_cid = CID.readLine();
Log.d(TAG, "CID of the MMC = " + sd_cid);
} catch (Exception e) {
Log.e("CID_APP", "Can not read SD-card cid");
}
} else {
Toast.makeText(this, "External Storage Not available!!",
Toast.LENGTH_SHORT).show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With