hey all, i have built a SQLite database and wanna to add into iphone app. already i have add it resource->add->x.sqlite and also add libsqlite3.0.dylib.framework but i don't know what is the showing code. how i can show it to iphone. .......
+1
A:
If you've added it to your project and have added the Framework then your app should be able to "see" the database. You just need to open it and query/write to it.
You get the path to the database something like this:
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"my.db"];
And then open it like this:
sqlite3_open([path UTF8String], &database);
Note that referring directly to the resource like this means your database will be read-only. You need to copy it elsewhere if you want to insert/update data.
Stephen Darlington
2009-01-28 12:36:45
+1
A:
Take a look at the SQLite Books sample. It does exactly what you are asking about.
http://developer.apple.com/iphone/library/samplecode/SQLiteBooks/index.html
Lounges
2009-01-28 17:51:54