0

I'm developing an android media player to play song from memory card.However I need the proper detection of memory cards (removable media). Can I get information about the inserted media - type, manufacturer, etc?

user3103779
  • 7
  • 1
  • 4
  • this links may helpful http://stackoverflow.com/questions/16267116/how-to-get-actual-size-of-mounted-sd-card-in-android?answertab=active#tab-top http://stackoverflow.com/questions/16834964/how-to-get-an-external-storage-sd-card-size-with-mounted-sd-card?answertab=active#tab-top – Ag.Pro. Dev Mar 15 '15 at 05:31
  • Why do you need to know the manufacturer? In any case, register a broadcast receiver to be notified of the event and let the media scanner give you the meta information about any new media files it detects. – Stephan Branczyk Mar 15 '15 at 05:32
  • I need total information about memory card because I want to bind the song with this memory card. if the song is copied to the other memory card the song wont be played by the media player. @StephanBranczyk – user3103779 Mar 15 '15 at 05:44
  • So that I can identify the Sdcard uniquely @StephanBranczyk – user3103779 Mar 15 '15 at 05:49
  • this might help you get the file system type: http://stackoverflow.com/questions/27227198/how-do-i-check-the-sd-cards-filesystem-type-such-as-ntfs-fat32-etc/27716696#27716696 – samgak Mar 15 '15 at 13:04

1 Answers1

0
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);
            tv.setText("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();
    }

}

private boolean isExteranlStorageAvailable() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return true;
    }
    return false;
}

this gives me a write way.

user3103779
  • 7
  • 1
  • 4