How to check a file's existence in phone directory with phonegap

后端 未结 14 1993
太阳男子
太阳男子 2020-12-05 10:49

I\'m writing an Android application with Phonegap 1.4.1 and Sencha that downloads and reads pdf files. How can I check whether the file exists in the phone directory using e

14条回答
  •  温柔的废话
    2020-12-05 11:26

    note:

    when I get the filesystem I save it in a var under a macro pg object:

    pg = {fs:{}}    // I have a "GOTFS" function... a "fail" function
    pg.fs.filesystem = window.requestFileSystem(window.PERSISTENT, 0, pg.fs.GOTFS, pg.fs.fail);
    

    so my code is pretty simple...

    var fileExists = function(path, existsCallback, dontExistsCallback){
        pg.fs.fileSystem.root.getFile(path, { create: false }, existsCallback, dontExistsCallback);
            // "existsCallback" will get fileEntry as first param
        }
    

提交回复
热议问题