2017-02-08 7 views
0

外部ディレクトリからファイルを読み込みたいのですが、cordova.file.externalRootDirectoryは常に内部デバイスメモリ "file:/// storage/emulated/0 /"を返します。cordova.file.externalRootDirectoryの問題

答えて

0

pleseは、私はあなたがcordova-diagnostic-pluginの​​方法は、着脱可能なマイクロSDカードの場所への参照を取得するために使用することができhttps://www.raymondcamden.com/2014/07/15/Cordova-Sample-Reading-a-text-file

+0

おかげで、しかし、ミューの問題は外部SDカード(私はマイクロカードを挿入した)からファイルを読み取ることでした、私はcordroid.file.externalRootDirectoryを使用してもアンドロイドの内部メモリを持っています。 – YasZe

0

このリンクで解決策を見つけることを願っていたリンクは、次のとおりです。

cordova.plugins.diagnostic.getExternalSdCardDetails(function(details){ 
    details.forEach(function(detail){ 
     if(type === "application"){ 
      console.log("Writable?" + detail.canWrite); //TRUE 
      cordova.file.externalSdCardApplicationStorageDirectory = detail.filePath; 
      // Write files to external SD card using this 
     }else{ // type === "root" 
      console.log("Writable?" + detail.canWrite); //FALSE 
      cordova.file.externalSdCardRootDirectory = detail.filePath; 
      // Read files from external SD card root using this 
     } 
    }); 
}, function(error){ 
    console.error(error); 
}); 
+0

ありがとう、働いていない:( – YasZe

+0

'getExternalSdCardDetails()'の使い方を示す[example project](https://github.com/dpa99c/cordova-diagnostic-plugin-example)を試してみてください。私はcordova -diagnostic-pluginですので、この例がうまくいかない場合は、テストデバイスの詳細に関する問題を開くことができれば幸いです。 – DaveAlden

関連する問題