Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- docsDir = [dirPaths objectAtIndex:0];
- _dicData = [[NSMutableDictionary alloc] init];
- // Build the path to the database file
- databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"Database.sqlite"]];
- NSLog(@"Data %@",databasePath);
- NSFileManager *filemgr = [NSFileManager defaultManager];
- if ([filemgr fileExistsAtPath: databasePath ] == NO)
- {
- const char *dbpath = [databasePath UTF8String];
- if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
- {
- char *errMsg;
- const char *sql_stmt = "CREATE TABLE IF NOT EXISTS Info(ID INTEGER PRIMARY KEY AUTOINCREMENT, ALERT TEXT, XREF TEXT, text TEXT , GRAPHIC Text , PROMPT TEXT , VOICE TEXT)";
- if (sqlite3_exec(contactDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK)
- {
- _lblstatus.text = @"Failed to create table";
- NSLog(@"SSS %@",_lblstatus.text);
- }
- sqlite3_close(contactDB);
- } else {
- _lblstatus.text = @"Failed to open/create database";
- NSLog(@"SSS %@",_lblstatus.text);
- }
- - (IBAction)btnSave:(id)sender {
- sqlite3_stmt *statement;
- const char *dbpath = [databasePath UTF8String];
- if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
- {
- NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO Info(ID, ALERT, XREF,TEXT,GRAPHIC,PROMPT,VOICE) VALUES ("%@", "%@", "%@","%@","%@","%@","%@")", _lblID.text, _lblAlert.text, _lblxref.text,_lbltext.text, _lblgraphic.text, _lblprompt.text,_lblvoice.text];
- NSLog(@"DDD %@",insertSQL);
- const char *insert_stmt = [insertSQL UTF8String];
- sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);
- NSLog(@"Error");
- /* if (sqlite3_step(statement) == SQLITE_DONE)
- {
- _lblstatus.text = @"Contact added";
- } else {
- _lblstatus.text = @"Failed to add contact";
- }*/
- sqlite3_finalize(statement);
- sqlite3_close(contactDB);
- }
- }
Add Comment
Please, Sign In to add comment