0
votes

I'm trying to reach the sqlite database from an app made with ionic. when making the app with ionic, the database is stored in this directory:

/Users/sistemas/Library/Developer/CoreSimulator/Devices/{alfanumeric}/data/Containers/Data/Application/{alfanumeric}/Library/LocalDatabase/test.db

But when i run the app made in xcode (8.2), the file is generated in another directory:

/Users/sistemas/Library/Developer/CoreSimulator/Devices/{alfanumeric}/data/Containers/Data/Application/{alfanumeric}/Documents/test.db

I have both database files in the xcode-made app and don't know how to reach the first test.db. Has anybody the solution to it?

1

1 Answers

0
votes

Just changed a little mi original method for calling the database..

let fileURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
        .appendingPathComponent("test.db")

To:

let fileURL = try! FileManager.default.url(for: .libraryDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
        .appendingPathComponent("LocalDatabase/test.db")

You can set the enum "FileManager.SearchPathDirectory" of the app from .documentDirectory to .libraryDirectory and just appended "LocalDatabase/".