NSArray *documentpath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* path = [documentpath objectAtIndex:0];
NSString *dbpath = [path stringByAppendingString:@"check1.sqlite"];
if (sqlite3_open([dbpath UTF8String], &db) == SQLITE_OK) {
NSLog(@"get database");
const char *sql = "select name from login where ID = 1";
sqlite3_stmt *statement;
int sqlresult = sqlite3_prepare_v2(db, sql, -1, &statement, NULL);
if ( sqlresult == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
NSString *name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1) ];
NSLog(@"%@",name);
}
}
}