Skip to content

Instantly share code, notes, and snippets.

@shazron
Created August 3, 2012 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shazron/3243819 to your computer and use it in GitHub Desktop.
Save shazron/3243819 to your computer and use it in GitHub Desktop.
setting com.apple.MobileBackup for Cordova
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