What different between store database in different locations in iOS?

后端 未结 1 1834
无人及你
无人及你 2021-01-06 20:25

I\'m working with SQLite.swift. In the document, the path to the database is:

let path = NSSearchPathForDirectoriesInDomains(
                .DocumentDirect         


        
相关标签:
1条回答
  • 2021-01-06 20:46

    The main difference is that storing the file in the documents folder means you can write (update) it, which is pretty important for a database file. You cannot write to a file in the app bundle.

    The usual pattern for using a database in an app is:

    1. Create a pre-seeded database during development and copy it to the app bundle during building.
    2. When running, check if the database file exists and is up-to-date in the documents folder.
    3. If not, copy it from the app bundle.
    4. Open the database in the documents folder and read/write as desired.
    0 讨论(0)
提交回复
热议问题