【发布时间】:2016-03-24 00:15:18
【问题描述】:
- (void) copyDatabaseIfNeeded
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ABC.Sqlite];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:ABC.Sqlite];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (success)
{
NSURL *url=[NSURL URLWithString:WSURL2];
} else
{
NSLog(@"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
我需要添加任何代码来查看 Sqlite 文件??
我尝试在 Plist 中添加这些:UIFileSharingEnabled、CFBundleDisplayName
如何在 iTunes 中查看我的 SQLite 文件?
参考链接: How to enable file sharing for my app?, UIFileSharingEnabled has no effect
如果我在我的应用中启用了 iTunes 文件共享选项来备份 PC 中的应用数据,appStore 会拒绝该应用吗?
【问题讨论】:
-
您是否将文件存储在应用程序的 Documents 文件夹中?显示一些相关代码。
-
我已经编辑了代码请检查一次,我需要添加任何代码来查看 Sqlite 文件?? @rmaddy
标签: ios objective-c iphone sqlite