Jquery mobile 如何在iphone和android中创建目录中的文件夹
您能告诉我如何在android(SD卡)和IOS的目录中创建文件夹吗?我还需要计算同一目录中的文件夹数。 我有目录File://SDCard/test . 在应用程序启动期间,我需要计算dame目录中的文件夹数 IPhone的目录是什么 看看基于W3C文件API的。它用于读取、写入和浏览文件系统层次结构 列出文件和文件夹 为了列出/计算目录中的列表和文件,必须使用对象 支持的平台:Jquery mobile 如何在iphone和android中创建目录中的文件夹,jquery-mobile,cordova,Jquery Mobile,Cordova,您能告诉我如何在android(SD卡)和IOS的目录中创建文件夹吗?我还需要计算同一目录中的文件夹数。 我有目录File://SDCard/test . 在应用程序启动期间,我需要计算dame目录中的文件夹数 IPhone的目录是什么 看看基于W3C文件API的。它用于读取、写入和浏览文件系统层次结构 列出文件和文件夹 为了列出/计算目录中的列表和文件,必须使用对象 支持的平台: 安卓 BlackBerry WebWorks(操作系统5.0及更高版本) iOS Windows Phone 7
- 安卓
- BlackBerry WebWorks(操作系统5.0及更高版本)
- iOS
- Windows Phone 7和8
- 视窗8
function success(entries) {
var i;
for (i=0; i<entries.length; i++) {
console.log(entries[i].name);
}
}
function fail(error) {
alert("Failed to list directory contents: " + error.code);
}
// Get a directory reader
var directoryReader = dirEntry.createReader();
// Get a list of all the entries in the directory
directoryReader.readEntries(success,fail);
<!DOCTYPE html>
<html>
<head>
<title>Local File System Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);
}
function onFileSystemSuccess(fileSystem) {
console.log(fileSystem.name);
var directoryEntry = fileSystem.root;
directoryEntry.getDirectory("newDir", {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail)
}
function onDirectorySuccess(parent) {
console.log(parent);
}
function onDirectoryFail(error) {
alert("Unable to create new directory: " + error.code);
}
function onFileSystemFail(evt) {
console.log(evt.target.error.code);
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Local File System</p>
</body>
</html>
我希望这能有所帮助。谢谢重播。你能告诉我这个“newDir”中的内容吗?这样我就可以在模拟器(iphone)上检查。如果成功,我如何在模拟器上检查它。在iOS中,此代码将在Applications/PHONEGAP\u APP/Documents/中创建一个名为“newDir”的文件夹。在Android中,如果设备有SD卡,此代码将在SD卡存储的根目录中创建“newDir”目录。否则将在内部存储器中创建。应用程序/PHONEGAP\u应用程序/Documents/。。?签入模拟器在哪里?我没有找到任何这些文件夹完整路径是/var/手机/应用程序/手机应用程序/文档/。但是,当使用iPhone模拟器时,路径是/Users/loginname/Library/Application Support/iPhone simulator/6.1/Applications/YOUR_APP/DocumentsHello我能够创建文件夹如何在该文件夹中创建文本文件?