【问题标题】:sqlite database opens fine on the iPhone simulator, but not on the devicesqlite 数据库在 iPhone 模拟器上可以正常打开,但不能在设备上打开
【发布时间】:2011-02-15 06:30:49
【问题描述】:

为什么这会在 iPhone 模拟器上运行良好...但数据库不能 在 iPhone 设备上打开?

sqlite3 *g_Db = nil;

BOOL OpenDatabase(NSString *databaseName)
{
    if(sqlite3_open([databaseName UTF8String], &g_Db) == SQLITE_OK)
    {
        NSLog(@"Opened db ok");
        return(YES);
    }
    else
    {
        NSLog(@"Can't open the db");
        sqlite3_close(g_Db);
        g_Db = nil;
        return(NO);
    }
}

【问题讨论】:

    标签: iphone database sqlite ios-simulator


    【解决方案1】:

    如果数据库还不存在并且您使用 SQLite 的功能在第一次引用时创建数据库,那么文件路径必须指向 iPhone 的文档目录(或 tmp),因为您可以写入应用程序包目录由于权限,在模拟器中但不在设备上。这是唯一让我感到惊讶的事情,因为两者之间明显不同,这会影响 SQLite 代码。

    【讨论】:

    • 呃……我忘了。让我检查一下……但我敢打赌就是这样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-08
    • 2011-06-06
    • 2014-05-12
    • 2013-08-13
    • 2016-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多