我想在我的应用程序中以编程方式获取CID编号。我使用以下代码:
public void getCID() {
File input = new File("/sys/class/mmc_host/mmc1");
String cidDirectory = null;
File[] sid = input.listFiles();
for (int i = 0; i < sid.length; i++) {
if (sid[i].toString().contains("mmc1:")) {
cidDirectory = sid[i].toString();
String SID = (String) sid[i].toString().subSequence(cidDirectory.length() - 4, cidDirectory.length());
Log.d("MainActivity", "SID of MMC = " + SID);
}
}
try {
BufferedReader CID = new BufferedReader(new FileReader(cidDirectory + "/cid"));
String sdCid = CID.readLine();
mCidNo = sdCid.toString();
Log.d("RegistrationActivity::", "CID :sdCid.length() = " + sdCid.length());
} catch (FileNotFoundException e) {
Log.d("RegistrationActivity::", e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.d("RegistrationActivity::", e.getMessage());
e.printStackTrace();
}
}
问题是CID号码的最后2位数字正在从手机变为手机。当我解码CID号时,我发现它是校验和。如何将CID号码用作唯一号码?或者我可以将任何其他字段用作SD卡唯一编号吗?