The original Article address is here
The principle is actually very simple. It is to package the file containing the original data in the project file,
When you start running for the first time, copy it to the Resource Directory (otherwise, the write operation cannot be performed in the original directory ).
Code Nsstring * Storepath = [[Self applicationdocumentsdirectory]
Stringbyappendingpathcomponent: @" Failedbankscd. SQLite " ];
// Put down default dB if it doesn' t already exist
Nsurl * Storeurl = [Nsurl fileurlwithpath: storepath];
Nsfilemanager * Filemanager = [Nsfilemanager defaultmanager];
If ( ! [Filemanager fileexistsatpath: storepath]) {
Nsstring * Defaultstorepath = [[Nsbundle mainbundle]
Pathforresource: @" Failedbankscd " Oftype: @" SQLite " ];
If (Defastorstorepath ){
[Filemanager copyitematpath: defaultstorepath topath: storepath error: NULL];
}
}