ios sqlite open failed

ios sqlite open failed
0.0 0


hi ,all :
I cannot understand why sqlite3_open FAILED in cocos2d-x .In cocos2d-iPhone I do like this

NSArray paths = NSSearchPathForDirectoriesInDomains;
documents = [paths objectAtIndex:0];
NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
if (sqlite3_open([database_path UTF8String], &db) != SQLITE_OK) {

And in cocos2d-x when i enter the Documents directory ,I found no db was established ,what should I do to solve this problem


sorry ,i solved it by this

sqlite3 pDB = NULL;//数据库指针
errMsg = NULL;//错误信息
std::string sqlstr;//SQL指令
int result;//sqlite3_exec返回值
CCFileUtils* fileUtils = CCFileUtils::sharedFileUtils();
const char* fileName = “save.db”;
// //打开一个数据库,如果该数据库不存在,则创建一个数据库文件
string path = fileUtils->fullPathFromRelativePath(fileName);
CCLog(“path is s",path.c_str());
result = sqlite3_open(path.c_str(), &pDB);
if( result != SQLITE_OK )
CCLog( "打开数据库失败,错误码:d ,错误原因:%s\n” , result, errMsg );

using CCFileUtils