What is the proper location for a sqlite3 database file?
Posted
by Elliot Chen
on Stack Overflow
See other posts from Stack Overflow
or by Elliot Chen
Published on 2010-05-09T14:30:23Z
Indexed on
2010/05/09
16:18 UTC
Read the original article
Hit count: 271
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!
© Stack Overflow or respective owner