[英]How can I get memory card information?
I'm developing an android media player to play song from memory card.However I need the proper detection of memory cards (removable media). 我正在开发一个Android媒体播放器来播放存储卡中的歌曲。但是,我需要正确检测存储卡(可移动媒体)。 Can I get information about the inserted media - type, manufacturer, etc? 我可以获取有关插入的介质的信息-类型,制造商等吗?
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. 这给了我一种书写方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.