在PhoneGap应用程序中创建目录 [英] Create a Directory in PhoneGap Application
本文介绍了在PhoneGap应用程序中创建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试找出如何使用PhoneGap在文件系统上创建目录。
Trying to figure out how to create a directory on the file system using PhoneGap.
我想为我的PhoneGap应用程序创建一个目录,
I want to create a directory for my PhoneGap application, so I can store images the user creates there and load them back up in the app.
推荐答案
这是您的操作方式:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null);
function onRequestFileSystemSuccess(fileSystem) {
var entry=fileSystem.root;
entry.getDirectory("example", {create: true, exclusive: false}, onGetDirectorySuccess, onGetDirectoryFail);
}
function onGetDirectorySuccess(dir) {
console.log("Created dir "+dir.name);
}
function onGetDirectoryFail(error) {
console.log("Error creating directory "+error.code);
}
在iOS上,此脚本将在应用程序中创建一个名为example的目录, YOUR_APP / Documents /
On iOS, this script will create a directory named 'example' in Applications/YOUR_APP/Documents/
这篇关于在PhoneGap应用程序中创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文