Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. NSString *DocsDir;
  2. NSArray * DirPath;
  3.  
  4. // getting the documents directory
  5. DirPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  6. DocsDir = DirPath[0];
  7.  
  8. DataBasePath = [[NSString alloc] initWithString:[DocsDir stringByAppendingPathComponent:@"MLGBoxDB.db"]];
  9. NSLog(@"%@",self.DataBasePath);
  10. NSFileManager *FileMangr = [NSFileManager defaultManager];
  11.  
  12. if ([FileMangr fileExistsAtPath:DataBasePath]==YES)
  13. {
  14. const char *dbPath =[DataBasePath UTF8String];
  15. if (sqlite3_open(dbPath, &MLGBoxDB)==SQLITE_OK)
  16. {
  17. char * errorMsg;
  18. //CREATE TABLE NAMED MLGBOXGAME
  19. const char *Sql_Stetment = "CREATE TABLE IF NOT EXISTS MLGBOXGAME(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT)";
  20. if (sqlite3_exec(MLGBoxDB, Sql_Stetment, NULL, NULL, &errorMsg)!= SQLITE_OK)
  21. {
  22. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to create table"
  23. message:@"Failed to create Player Name table"
  24. delegate:nil
  25. cancelButtonTitle:@"OK"
  26. otherButtonTitles:nil];
  27. [alert show];
  28.  
  29. } sqlite3_close(MLGBoxDB);
  30. }
  31. else
  32. {
  33. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to open database"
  34. message:@"Failed to open database"
  35. delegate:nil
  36. cancelButtonTitle:@"OK"
  37. otherButtonTitles:nil];
  38. [alert show];
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement