我正在尝试使用直接链接作为源路径从我的 Dropbox 下载 sqlite 数据库,然后将其保存到应用程序的文档文件中。这只是一种无需更新应用程序即可更新数据库的方法。
当我在下载前检查文件是否存在时,该文件不可见。
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *sourceDBPath = @"https://www.dropbox.com/s/868vvg7uremst9n/Data.sqlite?dl=1";
if ([fileManager fileExistsAtPath:sourceDBPath])
{
NSData *dbFile = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"https://www.dropbox.com/s/868vvg7uremst9n/Data.sqlite?dl=1"]];
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"Database.sqlite"];
[dbFile writeToFile:filePath atomically:YES];
}
即使我使用文件的直接链接,我是否需要将 Dropbox SDK 集成到我的应用程序中?