0
onDeviceReady 내에서 window.requestFileSystem ...을 호출하는 대신 PhoneGap의 설명서에서 제공하는 예제를 따르려고합니다. 실제로 특정 파일에 액세스해야 할 때마다 호출하고 있습니다. 웬일인지, 나의 코드는 그 선로를지나 가지 않는 것처럼 보인다.PhoneGap에서 SD 카드의 파일을 읽는 방법?
function pullSelectRecord(link)
{
selectedFile = link;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
alert("this is" + selectedFile);
fileSystem.root.getFile(link, null, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.file(gotFile, fail);
}
function gotFile(file){
readDataUrl(file);
readAsText(file);
}
function readAsText(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
alert(evt.target.result);
};
reader.readAsText(file);
}