iOS application base path

2019-02-19 23:14发布

问题:

I am currently developing an application using Phonegap / Jekyll / Backbone. I am however in the need for a base path for my generation of static content. For Android platforms I use /android_asset/www/ which is working fine. I am however unable to find one for iOS, anyone has any idea about it?

Thanks in advance.

回答1:

You have to asynchronously ask the iOS device to give you the root path. In deviceready function call:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFS, null);

When ready it will callback with a FileSystem object from which you can access the full root path.

function onFS(fs) {
    alert(fs.root.fullPath); 
}

Read more on PhoneGap/Cordova docs: http://docs.phonegap.com/en/edge/cordova_file_file.md.html#FileSystem