=> Hare Call the Method Of Whitch Declared Belove Side:
-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self createDb];
return YES;
}
==> Create One Databse File And Create Db And Usingf Some Method:
-(void)createDb
{
NSArray *dir=NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dbPath=[NSString
stringWithFormat:@"%@/userDb.sqlite",[dir lastObject]];
sqlite3 *db;
NSFileManager *fm=[NSFileManager new];
if([fm fileExistsAtPath:dbPath isDirectory:nil])
{
NSLog(@"Database already exists..");
return;
}
if (sqlite3_open([dbPath UTF8String],&db)==SQLITE_OK)
{
const char *query="create table user
(userName VARCHAR(20),userAdd VARCHAR(20), userPass VARCHAR(20))";
if (sqlite3_exec(db, query, NULL, NULL, NULL)==SQLITE_OK)
{
NSLog(@"User table created successfully..");
}else
{
NSLog(@"User table creation failed..");
}
}else
{
NSLog(@"Open table failed..");
}
sqlite3_close(db);
}
-(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self createDb];
return YES;
}
==> Create One Databse File And Create Db And Usingf Some Method:
-(void)createDb
{
NSArray *dir=NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dbPath=[NSString
stringWithFormat:@"%@/userDb.sqlite",[dir lastObject]];
sqlite3 *db;
NSFileManager *fm=[NSFileManager new];
if([fm fileExistsAtPath:dbPath isDirectory:nil])
{
NSLog(@"Database already exists..");
return;
}
if (sqlite3_open([dbPath UTF8String],&db)==SQLITE_OK)
{
const char *query="create table user
(userName VARCHAR(20),userAdd VARCHAR(20), userPass VARCHAR(20))";
if (sqlite3_exec(db, query, NULL, NULL, NULL)==SQLITE_OK)
{
NSLog(@"User table created successfully..");
}else
{
NSLog(@"User table creation failed..");
}
}else
{
NSLog(@"Open table failed..");
}
sqlite3_close(db);
}