nsarray *documentpaths = Nssearchpathfordirectoriesindomains(nsdocumentdirectory, NSUserDomainMask ,YES); use the C function nssearchpathfordirectoriesindomains to get the full path of the directory in the sandbox.
NSString * documentsDirectoryPath = [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, NSUserDomainMask , YES) objectatindex:0];
nsstring *ourdocumentpath =[documentpaths Objectatindex:0];
nsstring *sandboxpath = nshomedirectory ();
NSString *documentpath = [Sandboxpath stringbyappendingpathcomponent:@ "Purchase.app"];//the documents Add to Sandbox path//stringbyappendingpathcomponent
nsstring *filename=[ourdocumentpath stringbyappendingpathcomponent:_filename]; FileName is the file name of the saved files
NSLog (FileName);
Nsfilemanager *filemanager = [Nsfilemanager Defaultmanager];
Copy the database SQL file from the ResourcePath to the Documentpath
if ([FileManager fileexistsatpath:filename])
{
return FileName;
}Else
{
Nsurl *url = [nsurl Urlwithstring:fileurl];
NSData *data = [nsdata Datawithcontentsofurl:url];
[Data writetofile: FileName atomically:YES];// writes the NSData type Object data to the file, File name is filename
}
return FileName;
iOS file download