-(voID)openDataBase{// First,test for existence.BOol success;NS@R_502_6852@Manager *@R_502_6852@Manager = [NS@R_502_6852@Manager defaultManager];NSError *error;NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES);Nsstring *documentsDirectory = [paths objectAtIndex:0];Nsstring *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"Demo.sqlite"];success = [@R_502_6852@Manager @R_502_6852@ExistsAtPath:writableDBPath];if (success){ NSData *data=[[NSData alloc]initWithContentsOf@R_502_6852@:writableDBPath]; Nsstring * _key = @"111"; NSData *decryptedData = [data AES256DecryptWithKey:_key]; [@R_502_6852@Manager create@R_502_6852@AtPath:writableDBPath contents:decryptedData attributes:nil]; return;}// The writable database does not exist,so copy the default to the appropriate location.Nsstring *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Demo.sqlite"];NSData *sqliteData = [NSData dataWithContentsOf@R_502_6852@:defaultDBPath];Nsstring * _key = @"111";NSData *encryptedData = [sqliteData AES256EncryptWithKey:_key];success= [@R_502_6852@Manager create@R_502_6852@AtPath:writableDBPath contents:encryptedData attributes:nil];if (!success){ NSAssert1(0,@"Failed to create writable database @R_502_6852@ with message '%@'.",[error localizedDescription]);} }
我的代码有什么问题,我想我一直在创建新的sqlite文件但是如何解决这个问题呢?
任何人都可以帮助我如何将NSData转换为sqlite文件.
我应该在库中编写sqlite文件,然后从那里访问它吗?
但每次更新都会解密sqlite文件,我必须解密它.
以上是内存溢出为你收集整理的ios – 将sqlite数据库转换为nsdata并返回全部内容,希望文章能够帮你解决ios – 将sqlite数据库转换为nsdata并返回所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)