即時搜索一些小時,但我無法找到我的數據庫創建的iOS應用程序的xcode的路徑。該數據庫存在,導致其將數據加載到我的應用程序,但我找不到我的數據庫的路徑。即時通訊使用Xcode 4.5和iOS模擬器6.0。Xcode無法找到我的數據庫的路徑
我發現一些文件夾下的Xcode /內容/我搜索我的數據庫,但它沒有成功^^。
那麼它現在存儲在哪裏?
- (void)createOrOpenDB {
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [path objectAtIndex:0];
dbPathString = [docPath stringByAppendingPathComponent:@"WorkoutPlans.db"];
char *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
//[fileManager removeItemAtPath:dbPathString error:nil];
if(![fileManager fileExistsAtPath:dbPathString]) {
const char *dbPath = [dbPathString UTF8String];
if (sqlite3_open(dbPath, &workoutPlansDB) == SQLITE_OK) {
const char *sql_cr_wp = "CREATE TABLE IF NOT EXISTS WORKOUTPLANS (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE , DESCRIPTION TEXT NOT NULL UNIQUE)";
const char *sql_cr_en = "CREATE TABLE IF NOT EXISTS ENTITY (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE , DESCRIPTION TEXT NOT NULL UNIQUE)";
const char *sql_cr_ex = "CREATE TABLE IF NOT EXISTS EXERCISE (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , NAME TEXT NOT NULL UNIQUE , DESCRIPTION TEXT NOT NULL UNIQUE , REPS TEXT NOT NULL , WEIGHT TEXT NOT NULL)";
const char *sql_cr_plen = "CREATE TABLE IF NOT EXISTS WPEN (PLANID, ENID, FOREIGN KEY(PLANID) REFERENCES WORKOUTPLANS(ID) ON DELETE CASCADE, FOREIGN KEY(ENID) REFERENCES ENTITY(ID) ON DELETE CASCADE)";
const char *sql_cr_enex = "CREATE TABLE IF NOT EXISTS ENEX (ENTITYID, EXERCISEID, FOREIGN KEY(ENTITYID) REFERENCES ENTITY(ID) ON DELETE CASCADE, FOREIGN KEY(EXERCISEID) REFERENCES EXERCISE(ID) ON DELETE CASCADE)";
sqlite3_exec(workoutPlansDB, sql_cr_wp, NULL, NULL, &error);
sqlite3_exec(workoutPlansDB, sql_cr_ex, NULL, NULL, &error);
sqlite3_exec(workoutPlansDB, sql_cr_en, NULL, NULL, &error);
sqlite3_exec(workoutPlansDB, sql_cr_plen, NULL, NULL, &error);
sqlite3_exec(workoutPlansDB, sql_cr_enex, NULL, NULL, &error);
sqlite3_close(workoutPlansDB);
}
}
}