Nsfilemanager *filemanager = [nsfilemanagerdefaultmanager];
nserror *error;
// Copy Local database files to the installation directory
nsarray *paths =nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, YES);
nsstring *documentdirectory = [Paths objectatindex:0];
//app The document directory path in the installation directory
nsstring *dbpath = [documentdirectory stringbyappendingpathcomponent:@ "Countrydictionary.db" ];
if ([FileManager fileexistsatpath:d bpath]==NO) {
// database file path in Project
nsstring *resourcepath = [[nsbundlemainbundle]pathforresource:@ " Countrydictionary "ofType:@" DB "];
[FileManagercopyitematpath: ResourcePath topath:d bpath error:&error];
}Else {
// Update the database file of the APP documnet directory, and then delete and then copy the latest database file if it exists. When the local database is well designed, the following code needs to be commented out.
nserror *error;
if ([FileManager removeitematpath:d bpatherror: &error]!=YES) {
NSLog(@ "Unable to delete file%@", [Errorlocalizeddescription] );
}
nsstring*resourcepath =[[nsbundlemainbundle] pathforresource:@ " Countrydictionary "ofType:@" DB "];
[FileManagercopyitematpath: ResourcePath topath:d bpath error:&error];
}
Copy database file to path