问题
I had the previous question here about database location. What different between store database in different locations in iOS?
I'm confused in copying pre-seeded database to the writable location.
Now, every time I run and build my app, the in-use database will be replaced by pre-seeded db.
And in the future, if I update my app version, how do I prevent the database from being replaced?
回答1:
how do I prevent the database from being replaced?
Check the destination before you copy the database. If there's already a file there, don't do the copy. You can use -[NSFileManager fileExistsAtPath:]
to check for an existing file.
来源:https://stackoverflow.com/questions/34614968/ios-how-to-copy-pre-seeded-database-at-the-first-running-app-with-sqlite-swift