ここで、レコードを静的にデータベースに挿入します。私の問題は、テーブルビューから sqlitedatabase に再コードを追加したいということです。
-(IBAction)favouriteButtonClick
{
NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [dirArray objectAtIndex:0];
databasePath = [docPath stringByAppendingPathComponent:@"favouritecontact"];
NSLog(@"Database path=>%@",databasePath);
sqlite3_stmt *statement;
const char *dbpath=[databasePath UTF8String];
if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
{
//NSString *insertSQL=[NSString stringWithFormat:@"INSERT INTO favourite(FirstName,LastName,FullName,HomeEmail,HomeEmail,WorkEmail,MobileNo)VALUES(\"%@\", \"%@\", \"%@\",\"%@\",\"%@\", \"%@\")",FirstName.text,LastName.text,FullName.text,HomeEmail.text,WorkEmail.text,MobileNo.text];
NSString *insertSQL=[NSString stringWithFormat:@"INSERT INTO favourite(FirstName,LastName,FullName,HomeEmail,WorkEmail,MobileNo)VALUES('ketan','yadav','ketanyadav', 'ky@gmail.com','ketanyadav@gmail.com','1122334455')"];
NSLog(@"insertsql%@",insertSQL);
const char *insert_stmt=[insertSQL UTF8String];
sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);
sqlite3_step(statement);
sqlite3_finalize(statement);
sqlite3_close(contactDB);
NSLog(@"Record add to database");
}
}