开发者

objective-c open database from a folder

开发者 https://www.devze.com 2023-04-04 14:10 出处:网络
I have an app that contains top level folder with subfolders in the app\'s package - not the Documents area.

I have an app that contains top level folder with subfolders in the app's package - not the Documents area.

Here's the structure:

Document/  
Library/  
appPackage  
/tmp

The folder is visible when you right-click the and select "show package contents".

The subfolder is in the appPackage and visible at this point. The subfolder in turn contains multiple folders each with database files with same name

appPackage/mainFolder/subFolder_1/app.sql  
                      subFolder_2/app.sql
                      subFolder_3/app.sql

I'd like to open one of these databases (depending on user's choice). Optimal way would be to open the database from the current location rather than copying it to the Documents area of the app. I am trying to avoid it.

My question is: How do I tell sqlite3 inter开发者_如何学运维face to open the database from one of these paths?

BTW, I am able to access a .txt file in these subfolders - but not sure about database.

All help appreciated. R/- : Sam


NSString *myPath = ...;
sqlite3 *db = NULL;
if (SQLITE_OK == sqlite3_open([myPath fileSystemRepresentation], &db) {
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消