I used swiftData
to store information on sqlite
database till today it will work fine and suddenly it created a new location of database as well as simulator location
when first time run it shows
/Users/div/Library/Developer/CoreSimulator/Devices/606D7F8E-2402-4782-ADEE-12725EDB203A/data/Containers/Data/Application/2DB733AF-2544-4256-B1E5-5E8725E51CDF/Documents/DataBase.db
second time
/Users/div/Library/Developer/CoreSimulator/Devices/606D7F8E-2402-4782-ADEE-12725EDB203A/data/Containers/Data/Application/551991FA-392A-40E9-810E-31CEFCD3069A/Documents/dataBase.db
third time
/Users/div/Library/Developer/CoreSimulator/Devices/606D7F8E-2402-4782-ADEE-12725EDB203A/data/Containers/Data/Application/03E4BE03-D6E7-47BF-A98D-A129DF09DD28/Documents/DataBase.db
i used this code
let fileManager = NSFileManager()
var Sourcepath = NSBundle.mainBundle().resourcePath?.stringByAppendingPathComponent("PhotoKeeper.db");
let docsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] as String
let databaseStr = "DataBase.db"
let dbPath = docsPath.stringByAppendingPathComponent(databaseStr)
println(dbPath)
if(fileManager .fileExistsAtPath(dbPath) == false) {
var error:NSError?
fileManager.copyItemAtPath(Sourcepath!, toPath: dbPath, error: &error)
println(error)
}
my problem is every time new instance of database is created i.e. if i insert 2 row and compile and run the app it will create new database with zero row