android 获取SD卡相关信息
Object localOb; String str1 = null; try { localOb = new FileReader("/sys/block/mmcblk0/device/type"); localOb = new BufferedReader((Reader) localOb).readLine() .toLowerCase().contentEquals("sd"); if (localOb != null) { str1 = "/sys/block/mmcblk0/device/"; } } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader("/sys/block/mmcblk1/device/type"); localOb = new BufferedReader((Reader) localOb).readLine() .toLowerCase().contentEquals("sd"); if (localOb != null) { str1 = "/sys/block/mmcblk1/device/"; } } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader("/sys/block/mmcblk2/device/type"); localOb = new BufferedReader((Reader) localOb).readLine() .toLowerCase().contentEquals("sd"); if (localOb != null) { str1 = "/sys/block/mmcblk2/device/"; } } catch (Exception e1) { System.out.println(e1.getMessage()); } localOb = ""; try { localOb = new FileReader(str1 + "name"); // 厂商 String sd_name = new BufferedReader((Reader) localOb).readLine(); System.out.println("name: " + sd_name); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "cid"); // SD Card ID String sd_cid = new BufferedReader((Reader) localOb).readLine(); System.out.println("cid: " + sd_cid); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "csd"); String sd_csd = new BufferedReader((Reader) localOb).readLine(); System.out.println("csd: " + sd_csd); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "fwrev"); // 固件编号 String sd_fwrev = new BufferedReader((Reader) localOb).readLine(); System.out.println("fwrev: " + sd_fwrev); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "hwrev"); // 硬件版本 String sd_hwrev = new BufferedReader((Reader) localOb).readLine(); System.out.println("hwrev: " + sd_hwrev); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "manfid"); // manufacture 制造 String sd_manfid = new BufferedReader((Reader) localOb).readLine(); System.out.println("manfid: " + sd_manfid); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "oemid"); // 原始设备制造商 String sd_oemid = new BufferedReader((Reader) localOb).readLine(); System.out.println("oemid: " + sd_oemid); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "scr"); String sd_scr = new BufferedReader((Reader) localOb).readLine(); System.out.println("scr: " + sd_scr); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "serial"); // 串号/序列号 String sd_serial = new BufferedReader((Reader) localOb).readLine(); System.out.println("serial: " + sd_serial); } catch (Exception e1) { System.out.println(e1.getMessage()); } try { localOb = new FileReader(str1 + "date"); // 生产日期 String sd_date = new BufferedReader((Reader) localOb).readLine(); System.out.println("date: " + sd_date); } catch (Exception e1) { System.out.println(e1.getMessage()); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。