Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *DocsDir;
- NSArray * DirPath;
- // getting the documents directory
- DirPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- DocsDir = DirPath[0];
- DataBasePath = [[NSString alloc] initWithString:[DocsDir stringByAppendingPathComponent:@"MLGBoxDB.db"]];
- NSLog(@"%@",self.DataBasePath);
- NSFileManager *FileMangr = [NSFileManager defaultManager];
- if ([FileMangr fileExistsAtPath:DataBasePath]==YES)
- {
- const char *dbPath =[DataBasePath UTF8String];
- if (sqlite3_open(dbPath, &MLGBoxDB)==SQLITE_OK)
- {
- char * errorMsg;
- //CREATE TABLE NAMED MLGBOXGAME
- const char *Sql_Stetment = "CREATE TABLE IF NOT EXISTS MLGBOXGAME(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT)";
- if (sqlite3_exec(MLGBoxDB, Sql_Stetment, NULL, NULL, &errorMsg)!= SQLITE_OK)
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to create table"
- message:@"Failed to create Player Name table"
- delegate:nil
- cancelButtonTitle:@"OK"
- otherButtonTitles:nil];
- [alert show];
- } sqlite3_close(MLGBoxDB);
- }
- else
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to open database"
- message:@"Failed to open database"
- delegate:nil
- cancelButtonTitle:@"OK"
- otherButtonTitles:nil];
- [alert show];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement