在哪里保存为iphone应用程序创建的本地数据库? [英] Where to save the local DB created for iphone app?
问题描述
我开发了一个加载完全静态内容的应用程序。我存储的数据大小超过4 mb。有了这个内容,应用程序将无法工作。在我的情况下,我应该保存本地数据库(文档文件夹或库文件夹)。
我的应用程序被备份为iCloud存储后被拒绝。
1)我应该在哪里保存数据库?在Library文件夹或Documents文件夹内?
2)由于苹果拒绝了我的应用程序,我相信我不应该备份数据库的iCloud。如果我错了,请更正我。
3)在我的应用程序中,我也采取屏幕截图并保存在文档目录中,以附加在邮件中。是否可以保存屏幕截图在文档目录或应该保存它的缓存文件夹?请更新。
请指导我实施DB的正确方法。
感谢
在将数据库保存到文档目录之前,请在应用程序中使用以下代码。
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char * filePath = [[URL path] fileSystemRepresentation];
const char * attrName =com.apple.MobileBackup;
u_int8_t attrValue = 1;
int result = setxattr(filePath,attrName,& attrValue,sizeof(attrValue),0,0);
// NSLog(@Attributs:%d and Path:%@,result,URL);
if(result!= 0){
NSLog(@文件备份属性设置错误);
}
return result == 0;
}
I have developed a app that loads fully static content . I am storing data more than 4 mb of size. With out this content the app will not work. In my case where should i save the local database(documents folder or library folder).
My app got rejected since it was backed up for iCloud storage.
1) Where should i save the database? In Library folder or inside Documents folder?
2) Since apple rejected my app i believe that I should not backup the database for iCloud. Please correct me if i was wrong.
3) In my app i am also taking screen shot and saving in document directory to attach it in mail. Whether can i save the screen shot in document directory or should i save it the caches folder? Please update.
Please guide me the right way to implement DB .
Thanks
Please use below code in your application before saving database to your document directory..
-(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
// NSLog(@"Attributs : %d and Path : %@",result,URL);
if (result != 0) {
NSLog(@"File Backup Attribute setting error");
}
return result == 0;
}
这篇关于在哪里保存为iphone应用程序创建的本地数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!