Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read the SD Card ID number?

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

like image 617
Eric Hamilton Avatar asked Jul 27 '10 22:07

Eric Hamilton


People also ask

Do SD cards have an ID number?

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.

How do I read my SD card information?

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.

How do I read Micro SD card numbers?

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.

How do I find my CID number on my SD card?

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.


1 Answers

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();
}
like image 156
Dinesh Prajapati Avatar answered Sep 17 '22 19:09

Dinesh Prajapati