以下是获取SID和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();

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐