how to get the full path of sdcard directory in android phonegap with javascript?

后端 未结 3 779
庸人自扰
庸人自扰 2021-01-19 17:26

I am using PhoneGap 2.8.0 for android app.

Need to get the full path of sdcard using javascript in phonegap, because in my mobile it shows the location as file

3条回答
  •  隐瞒了意图╮
    2021-01-19 18:12

    you can also get your directory by this code. code reference from phonegap documentation.

        document.addEventListener("deviceready", onDeviceReady, false);
    
        // device APIs are available
        //
        function onDeviceReady() {
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
        }
    
        function onFileSystemSuccess(fileSystem) {
            fileSystem.root.getDirectory("App_files", {create: false, exclusive: false}, onGetDirectoryWin, onGetDirectoryFail);
        }
    
        function fail(evt) {
            console.log(evt.target.error.code);
        }
    
        var onGetDirectoryWin = function(parent) {
    
        }
        var onGetDirectoryFail = function() {
            console.log("error getting dir")
        }
    

提交回复
热议问题