2011-08-01 7 views

答えて

1

これは、iPhoneアプリケーションでデータベースを作成する場所によって異なります。 私が作成した方法は、サンドボックスのドキュメントフォルダの下にあり、パスは常に同じです。

NSString *databaseName = @"mainDB.sqlite"; 
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDir = [documentPaths objectAtIndex:0]; 
databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; 

ように、データベースのパスです/ライブラリ/ Application Support/iPhoneシミュレータ/ 4.2 /アプリケーション//ドキュメント/ mainDB.sqlite

0

は、あなたのバンドルにあるデータベースを開くには、あなたが行うことができます:

sqlite3 *_database; 

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"yourDbName.extension"]; 

sqlite3_open_v2([path UTF8String], &_database, SQLITE_OPEN_READONLY, NULL); 
関連する問題