English 中文(简体)
iOS 5.1 找不到 Sqlite 文件
原标题:iOS 5.1 cant find sqlite file

I m having some trouble finding my sqlite file. When I run de app with iOS 5 simulator it runs ok but when I run it on iOS 5.1 it can t find the sqlite file. I m using this code to find the file.

- (NSString *) getDatabasePath {
    NSString* databaseName = @"bohn_db.bin.sqlite";
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    return [documentsDir stringByAppendingPathComponent:databaseName];      
}

在 iOS 5 和 iOS 5.1 上它没有, 我试图将文件从 de main bag 资源路径复制到文档路径( 以上路径), 它不工作导致文件在主 bunlde 资源路径中甚至找不到, 但文件在那里。 在 iOS 5.1 上会发生什么?

提前谢谢!

问题回答

我也有同样的问题。 在尝试了这么多不同的事情之后, 将数据库从程序中删除, 并重新添加了它。 这一次我确保我输入了“ 添加目标” 的支票。 这样做之后, 检查效果很好。 如果我没有检查它, 那么它就会复制文件 。

从模拟器中删除应用程序, 并构建和输入计时器, 以获得 DatabasePath 5 秒。 我认为它会有效 。

NSLog 数据库路径来自您的代码, 并手动检查它是否存在 。





相关问题
Code snippet paths in GCC

Background: Keil C51 on a PC, currently moving to GCC (CrossPack-AVR) on an iMac. Since I write firmware for micro s I have a lot of driver source files etc. that I need to include with my programs,...

C#/.NET app doesn t recognize Environment Var Change (PATH)

In my C# app, I am programmatically installing an Oracle client if one is not present, which requires adding a dir to the PATH system environment variable. This all works fine, but it doesn t take ...

PHP absolute path to file URI

In order to refer to a local DTD when using PHP SimpleXML, I need to convert the absolute path into a file type URI. For example, convert /home/sitename/www/xml/example.dtd to file:///home/sitename/...

Check if files with absolute and relative path exists

Is there a way to check whether files (with either an absolute or relative path) exists? Im using PHP. I found a couple of method but either they only accept absolute or relative but not both. Thanks.

How to get file path of the file with the running-vba code

I want to get the folder path from the file who is running the vba-code. For example: the vba-code is in the file C:myfolderfile.accdb and I want the vba-code to return C:myfolder Is that ...

热门标签