What should be proper location for sqlit3 database file?
- by Elliot Chen
Hi, Everyone:
I'm using a sqlite3 database to store app's data. Instead of building a database within program, I introduced an existing db file: 'abc.sqlite' into my project and put it under my 'Resources' folder.
So, I think this db file should be inside of 'bundle', so at my init function, I used following statement to read it out:
NSString *path = [[NSBundle mainBundle] pathForResource:@"abc" ofType:"sqlite"];
if(sqlite3_open([path UTF8String], &database) != SQLITE_OK)
...
It's ok that this db can be opened and data can be retrieved from it.
BUT, someone told me that it's better to copy this db file into user folder: such as 'Document'. So, my question is: is it ok to use this db from main bundle directly or copy it to user folder then use that copy. Which is better?
Thank you very much!