Created
August 3, 2012 02:49
-
-
Save shazron/3243819 to your computer and use it in GitHub Desktop.
setting com.apple.MobileBackup for Cordova
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("deviceready", onDeviceReady,false); | |
function setFolderMetadata(localFileSystem, subFolder, metadataKey, metadataValue) | |
{ | |
var onSetMetadataWin = function() { | |
console.log("success setting metadata") | |
} | |
var onSetMetadataFail = function() { | |
console.log("error setting metadata") | |
} | |
var onGetDirectoryWin = function(parent) { | |
parent.setMetadata(onSetMetadataWin, onSetMetadataFail, { metadataKey: metadataValue}); | |
} | |
var onGetDirectoryFail = function() { | |
console.log("error getting dir") | |
} | |
var onFSWin = function(fileSystem) { | |
fileSystem.root.getDirectory(subFolder, {create: true, exclusive: false}, onGetDirectoryWin, onGetDirectoryFail); | |
} | |
var onFSFail = function(evt) { | |
console.log(evt.target.error.code); | |
} | |
window.requestFileSystem(localFileSystem, 0, onFSWin, onFSFail); | |
} | |
function onDeviceReady() | |
{ | |
setFolderMetadata(LocalFileSystem.PERSISTENT, "Backups", "com.apple.MobileBackup", 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment