iphone - How to get SQLITE database file to sync in DropBox? -


i working on ipad app.here want upload whole database file dropbox.i searched on google didnot found appropriate solution.i used following code create database.

-(bool) createdatabasefile {      nsstring *docsdir; nsarray *dirpaths; nsfilemanager *filemgr = [nsfilemanager defaultmanager]; bool successmsg = yes; // documents directory dirpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,     nsuserdomainmask, yes); docsdir = [dirpaths objectatindex:0];  // build path database file self.detaildatabasepath = [[nsstring alloc] initwithstring:[docsdir stringbyappendingpathcomponent:@`"database.sql"`]]; // check existence of database file if ([filemgr fileexistsatpath:self.detaildatabasepath]) {     //file exists @ path } else {     //since file not available @ path create database file     successmsg = [filemgr createfileatpath:self.detaildatabasepath contents:[nsdata data] attributes:nil]; } return successmsg; } 

so how can "database.sql" file.please dont treat duplicate question.i had wasted day googling didnot find solution..please guide me.

thanks in advance

to upload file dropbox need dropbox sdks - https://www.dropbox.com/developers/sync/sdks/ios (how add dropbox.framework project)

then can upload file:

-(void) createbackupindropbox {     nsstring *filename = @"backup.sqlite"; //file name in dropbox     nsstring *destdir = @"/backups"; //destination path in dropbox     nsstring *frompath = @"..."; //local path db file     /*      nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);      nsstring *docspath = [paths objectatindex:0];      frompath = [docspath stringbyappendingpathcomponent:@"my_database.sqlite"];     */      [[self restclient] deletepath:[nsstring stringwithformat:@"%@/%@", destdir, filename]]; //delete file if need replace     [[self restclient] uploadfile:filename topath:destdir                     withparentrev:nil frompath:frompath]; } 

to control uploading process:

- (void)restclient:(dbrestclient*)client uploadedfile:(nsstring*)destpath               from:(nsstring*)srcpath metadata:(dbmetadata*)metadata {     nslog(@"file uploaded path: %@", metadata.path); }  - (void)restclient:(dbrestclient*)client uploadfilefailedwitherror:(nserror*)error {     [waitindicator dismisswithclickedbuttonindex:0 animated:yes];     nslog(@"file upload failed error - %@", error); }  - (void)restclient:(dbrestclient*)client uploadprogress:(cgfloat)progress forfile:(nsstring *)destpath from:(nsstring *)srcpath {  } 

and restclient method:

- (dbrestclient *)restclient {     if (!restclient) {         restclient = [[dbrestclient alloc] initwithsession:[dbsession sharedsession]];         restclient.delegate = self;     }     return restclient; } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -