在 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 上,此脚本将在 Applications/YOUR_APP/Documents/中创建一个名为example"的目录
On iOS, this script will create a directory named 'example' in Applications/YOUR_APP/Documents/
这篇关于在 PhoneGap 应用程序中创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文