Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default DB Storage location #344

Open
Bhide opened this issue Feb 23, 2023 · 1 comment
Open

Default DB Storage location #344

Bhide opened this issue Feb 23, 2023 · 1 comment

Comments

@Bhide
Copy link

Bhide commented Feb 23, 2023

The documentation states that the default location where the DB is stored is the Application Support Directory. However, the DB is actually stored in the Documents directory. It it a bug? Is there a way to specify the storage location?

@aomsir
Copy link

aomsir commented Oct 27, 2024

let fileManager = FileManager.default
    if let appSupportURL = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first {
        let dbURL = appSupportURL.appendingPathComponent("YourProjectName.sqlite")

        if !fileManager.fileExists(atPath: appSupportURL.path) {
            do {
                try fileManager.createDirectory(at: appSupportURL, withIntermediateDirectories: true, attributes: nil)
            } catch {
                fatalError("Failed to create Application Support directory: \(error)")
            }
        }

        let options: [AnyHashable: Any] = [
            EncryptedStorePassphraseKey: "123456", 
            EncryptedStoreDatabaseLocation: dbURL       
        ]

Just create it with this parameter, in the application support directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants