I'm busy creating the iOS 8 Today extension for my application. I want to access my SQLite database (not the main data) from my extension. After a short search on the Internet, I found out that I needed a group of applications. So I created an application group for my application called "group.AppName".
In the following code, I create a SQLite database in NSDocumentDirectory. But application extensions cannot access NSDocumentDirectory. Therefore, I want to save the SQLite database in my application group.
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docPath = [path objectAtIndex:0]; dbPathString = [docPath stringByAppendingPathComponent: @"dbName.db"]; char *error; NSFileManager *fileManager = [NSFileManager defaultManager]; if(![fileManager fileExistsAtPath:dbPathString]) { const char *dbPath = [dbPathString UTF8String]; if(sqlite3_open(dbPath, &treinAppDB) == SQLITE_OK) { const char *sql_stat = "CREATE TABLE IF NOT EXISTS table (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, code TEXT, lat TEXT, lon TEXT)"; sqlite3_exec(appDB, sql_stat, NULL, NULL, &error); sqlite3_close(appDB); } }
I canโt understand how I can create this database in my application group, so I can access the database from my Today extension.
Can someone help me with this problem? It would be great!
source share