2012-01-30 11 views

答えて

2

はい、これを試してみてください。 ます。http:// stackoverflowのを

public String getSDCARDiD() 
    { 
     String sd_cid = null; 
     try { 

      File file = new File("/sys/block/mmcblk1"); 
      String memBlk; 
      if (file.exists() && file.isDirectory()) { 

       memBlk = "mmcblk1"; 
      } else { 
       //System.out.println("not a directory"); 
       memBlk = "mmcblk0"; 
      } 

      Process cmd = Runtime.getRuntime().exec("cat /sys/block/"+memBlk+"/device/cid"); 
      BufferedReader br = new BufferedReader(new InputStreamReader(cmd.getInputStream())); 
      sd_cid = br.readLine(); 
      //System.out.println(sd_cid); 

     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
     return sd_cid; 
    } 
1

この

**way 1**  

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++) { 
      Log.d(TAG,"sid info "+sid[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 serial = new BufferedReader(new FileReader(cid_directory + "/serial")); 
     BufferedReader name = new BufferedReader(new FileReader(cid_directory + "/name")); 
     BufferedReader manfid = new BufferedReader(new FileReader(cid_directory + "/manfid")); 
     BufferedReader oemid = new BufferedReader(new FileReader(cid_directory + "/oemid")); 
     BufferedReader mfDate = new BufferedReader(new FileReader(cid_directory + "/date")); 
     BufferedReader CID = new BufferedReader(new FileReader(cid_directory + "/cid")); 


     String sdSerial = serial.readLine(); 
     String sdName = name.readLine(); 
     String sdMfId = manfid.readLine(); 
     String sdOemId = oemid.readLine(); 
     String sdMfDate = mfDate.readLine(); 
     String sdCid = CID.readLine(); 

**way 2** 

String path2 = "/sys/block/mmcblk0/device"; 

    BufferedReader serial; 
    BufferedReader name ; 
    BufferedReader manfid; 
    BufferedReader oemid; 
    BufferedReader mfDate; 
    BufferedReader CID; 

      serial = new BufferedReader(new FileReader(path2 + "/serial")); 
      name = new BufferedReader(new FileReader(path2 + "/name")); 
      manfid = new BufferedReader(new FileReader(path2 + "/manfid")); 
      oemid = new BufferedReader(new FileReader(path2 + "/oemid")); 
      mfDate = new BufferedReader(new FileReader(path2 + "/date")); 
      CID = new BufferedReader(new FileReader(path2 + "/cid")); 

     String sdSerial = serial.readLine(); 
     String sdName = name.readLine(); 
     String sdMfId = manfid.readLine(); 
     String sdOemId = oemid.readLine(); 
     String sdMfDate = mfDate.readLine(); 
     String sdCid = CID.readLine(); 

を試してみてください、これはこれを試してみてください