0

I am using Sqlite db into my application. As per some tutorial it is advised to me that move sqlite db file to document folder than use it to perform DB operations.

I have done the same and work perfectly.

But my question is that can we access the sqlite db from bundle and perform db operations. why it is advised to use from document folder?

Raj Aggrawal
  • 761
  • 1
  • 6
  • 21
  • 3
    Aggarwal The files on bundle is read only.To work on it you need to get it into document folder.For more detail check the answer here-: http://stackoverflow.com/questions/12679448/does-an-ios-app-have-write-access-inside-its-bundle – Tushar Sharma Apr 19 '17 at 10:25

1 Answers1

3

They probably want to guarantee its writable. iOS apps are sandboxed so you cannot actually overwrite the assets you include with your app; you can however, write to the document directory.

Josh Homann
  • 15,933
  • 3
  • 30
  • 33
  • Thanks for valuable answer. – Raj Aggrawal Apr 19 '17 at 10:29
  • If I dont want to modify means my data is static and read only so can we access that db?? – Raj Aggrawal Apr 19 '17 at 10:30
  • 1
    If you are not writing to it and SQlite does need to write to it, it should work. This is how, for instance, all of the UIImages in your asset catalog work. they are read from the bundle, but if you try to write to one of them it will fail. – Josh Homann Apr 19 '17 at 10:48