Code:
var root;
var imageCache;
//get the root of the application.
function getAppRoot() {
if (device.platform == "Android") {
window.resolveLocalFileSystemURI("file:///data/data/com.geveo.myapp", onSuccess, onError);
} else if (device.platform == "iOS") {
window.requestFileSystem(LocalFileSystem.PERSISTENT,0, function(fileSystem) {
root = fileSystem.root;
onSuccess(root);
}, function(evt) {
// error getting file system
console.log(evt.target.error.code);
});
}
}
//create cache if not exist iside root folder
function onSuccess(entry) {
root = entry;
root.getDirectory("ImageCache", {
create : true,
exclusive : false
}, onImageCacheCreateSuccess, onImageCacheCreateFail);
}
function onImageCacheCreateSuccess(dir) {
imageCache = dir;
console.log(dir.fullPath.toString());
}
function onImageCacheCreateFail(error) {
console.log("ImageCache Create Fail"+error.code );
}
function onError(error) {
console.log("Error"+error.code );
}
No comments:
Post a Comment