i'm working on cordova app windows 8 , trying use html5 file api file , copy destination.
i have local file in www
folder in folder called db
. javascript file located in www/js
folder.
i'm using code create instance of requestfilesystem()
:
window.requestfilesystem(window.temporary, 2 * 1024 * 1024, initfs, errorhandler); function initfs(fs) { console.log('woot!'); } function errorhandler(err) { console.log(err.code); }
inside initfs
function need file, test if exists @ destination, if doesn't copy file. want create copyfile
function , pass "from" directory, file, , destination
window.requestfilesystem(window.temporary, 2 * 1024 * 1024, initfs, errorhandler); function initfs(fs) { var fromlocation = [local db directory]; var myfile = [file stored in local db directory]; var tolocation = [destination copy to]; copyfile(fromlocation, myfile, tolocation); } function errorhandler(err) { console.log(err.code); } function copyfile(fromloc, src, toloc){ //copy file new location }
all examples i've read talk how create , manipulate file none talk manipulating file exists.
the way i'm fixing running sqlite statement using cordova sqlite storage plugin checks if table exists. if doesn't table created , set of inserts run. if table exist nothing happens.
the open db statement create db if 1 doesn't exist. if db exists isn't overwritten.
Comments
Post a Comment