2012-09-10 48 views
0

下面的代碼告訴我,MediaScanner在SD卡上啓動了,之後彈出爲什麼?發生了什麼?在SD卡被彈出後,MediaScanner在SD卡上運行?

if(intent.getDataString().equals("file:///mnt/extsd")) 
     { 
      if(Intent.ACTION_MEDIA_SCANNER_STARTED.equals(intent.getAction())) 
      { 
       //Media scanner is started 
      } 
      else if(Intent.ACTION_MEDIA_SCANNER_FINISHED.equals(intent.getAction())) 
      { 
      } 
     } 

回答

1

Probably this question will be helpfull其對/mnt/extsd以及如何正確使用SD卡(指Environment.getExternalStorageDirectory())。你也必須檢查SD卡狀態。我的意思是這樣的:

boolean isExternalStorageWriteable = false, isExternalStorageReadable = false; 
// Check SD Card for Read/Write 
if (Environment.MEDIA_MOUNTED.equals(state)) { 
    // We can read and write the media 
    isExternalStorageWriteable = true; 
    isExternalStorageReadable = true; 
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { 
    // We can only read the media 
    isExternalStorageReadable = true; 
} else { 
    // Something else is wrong. It may be one of many other states, but 
    // all we need 
    // to know is we can neither read nor write 
} 
+0

的事情是,到/ mnt/SD卡IS Environment.getExternalStorageDirectory的輸出(),但這種聯繫是有益的仍然 – Sojurn

+0

其實你也必須檢查SD卡狀態。我的意思是像下面的代碼。 – Stan