Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This might be of some use. Header File </p> <pre><code>NSString *databasePath; </code></pre> <p>.m File //Make a call to these Methods</p> <pre><code> [self checkAndCreateDB ]; [self alterDB]; -(void)checkAndCreateDB { NSString* databaseName = @"MasterDB.sqlite"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; BOOL success1; NSFileManager *fileManager = [NSFileManager defaultManager]; success1 = [fileManager fileExistsAtPath:databasePath]; if(success1) return; NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName]; [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; } -(void) alterDB{ sqlite3 *database; sqlite3_stmt *statement; if(sqlite3_open([databasePath UTF8String], &amp;database) == SQLITE_OK) { NSString *updateSQL = [NSString stringWithFormat: @"ALTER TABLE User ADD COLUMN testColumn TEXT"]; const char *update_stmt = [updateSQL UTF8String]; sqlite3_prepare_v2(database, update_stmt, -1, &amp;statement, NULL); if(sqlite3_step(statement)==SQLITE_DONE) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DB altered" message:@"Success" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; alert=nil; } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DB Updation" message:@"DB not Altered" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; alert=nil; } // Release the compiled statement from memory sqlite3_finalize(statement); sqlite3_close(database); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload