0

How can I copy sqlite file back to main bundle after updating the database? Now I copy sqlite file into Documents directory, insert new records than select all from it, and I can see that the data is there, old and new one. How to update the main database which I copied? Thank you for your time and help.

matt koder
  • 117
  • 12

2 Answers2

2

Actually you cannot change the app bundle files. Once you changed the app bundle files it invalidates the app sign and it will install anymore. You have to copy the app bundle files to App Documents directory and always use the files in documents directory.

https://stackoverflow.com/a/4764638/5019395

Community
  • 1
  • 1
shlok
  • 113
  • 8
1

No you can't copy sqlite file back to main bundle because app bundle is read-only!

larva
  • 4,687
  • 1
  • 24
  • 44
  • How can I update sqlite database then after changes? Because when I shut down the application, database is the same as it was on the beginning. No change is saved. – matt koder Nov 17 '15 at 09:22
  • 1
    You have to check if you've already copied the database from the bundle to the Documents directory. If you have, don't overwrite it. – Avi Nov 17 '15 at 09:27
  • 1
    @mattkoder just copy sqlite file to documents directory if it's not exist in documents – larva Nov 17 '15 at 09:28
  • i feel like such a noob... Thank you. I needed this line of code: if (![fileManager fileExistsAtPath:copyDBPath]) { } – matt koder Nov 17 '15 at 09:35