1
我有一个项目,其中包括FMDB来管理SQLite数据库。我导入并链接了FMDB包装,但问题是当我查询数据库时没有显示结果:iPhone fdbm SQLite没有读取数据
用Firefox SQLite管理器(Ubuntu)创建的sqlite数据库,我将它复制到Xcode。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *path = [docsPath stringByAppendingPathComponent:@"db.sqlite"];
FMDatabase *db = [FMDatabase databaseWithPath:path];
[db open];
FMResultSet *fResult= [db executeQuery:@"SELECT * FROM mytable"];
while([fResult next])
{
NSLog(@"%@",[fResult stringForColumn:@"title"]);
}
[db close];
其实我在iphone上使用fdbm和资源文件夹中的数据库文件 – shox 2011-12-28 08:55:50
如果数据库在资源文件夹中,那么在资源文件夹中寻找,而不是文件 - [[NSBundle mainBundle] pathForResource:@“db”ofType:@“源码“]; – Eugene 2011-12-28 08:57:33