2016-08-08 26 views
0

cordova.file.externalRootDirectory將一直存在,即使沒有SD卡,應用也會認爲存在SD卡。因此,下載到cordova.file.externalRootDirectory的文件將不存在。我如何確定何時在Android中使用cordova.file.externalRootDirectory?如果沒有我的文件成功下載到SD卡,我想使用cordova.file.dataDirectory。有沒有解決這個問題的方法?知道何時在Android中使用cordova.file.externalRootDirectory

回答

0

不知道你是否已經找到了答案 - 如果你沒有,你可以看看this answer here。代碼遍歷列表cordova.file.<xxx>項目,列出文件名(並遞歸到子目錄中)。如果您計劃列出目錄內容,則可以執行類似操作,只需要cordova.file.externalRootDirectorycordova.file.datadirectory

但是,如果您正在測試是否存在SD卡 - 比如寫入它 - 您只需檢查是否有任何條目cordova.file.externalRootDirectory(只需檢查以查看entries.length> 0)。如果有的話,你可以假設已經安裝了SD卡。

相關問題