<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Sample</title>
<script src="cordova-2.7.0.js" type="text/javascript"></script>
<script type="text/javascript">
if (!navigator.userAgent.toLowerCase().match('chrome')) {
document.write("<script src='phonegap.js'><\/script>");
}
</script>
</head>
<body onload="onLoaded()">
<div class="info" style="font-size:12px">CCN TEST</div>
<script>
function onLoaded() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onGetTmpFileSystemSuccess, onGetTmpFileSystemError);
}
function onGetTmpFileSystemSuccess(fileSystem){
var paths=fileSystem.root.fullPath.split("/");
var fullPath="file:///mnt/sdcard/Android/data/"+paths[paths.length-2];
alert(fullPath);
window.resolveLocalFileSystemURI(fullPath, onGetLocalFileSystemURISuccess, onGetLocalFileSystemURIError);
alert('GetTmpFileSystemSuccess');
}
function onGetTmpFileSystemError(fileSystem){
alert('GetTmpFileSystemError');
}
function onGetLocalFileSystemURISuccess(fileSystem){
fileSystem.getDirectory("app_newDir",{create:true, exclusive:false}, onCreateSuccess, onCreateError);
alert('GetLocalFileSystemURISuccess');
}
function onGetLocalFileSystemURIError(err){
alert('不能獲取指定檔目錄:'+err.code);
}
function onCreateSuccess(parent){
alert('成功建立目錄,路徑是:'+parent.fullPath);
}
function onCreateError(err){
alert('沒有成功建立目錄:'+err.code);
}
</script>
</body>
</html>
- Jun 06 Fri 2014 15:54
[PhoneGap] 在應用程式目錄下建立資料夾
全站熱搜
留言列表