今天在用fmdb对数据库进行操作的时候 一直无法在表中插入数据 最后才发现 NSBundle中的db文件是read-only属性 不能进行写操作!需要先拷贝到应用文件夹中
#define DBPATH [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingString:@"/word.db"]
NSFileManager *fileManager=[NSFileManagerdefaultManager];
if (![fileManagerfileExistsAtPath:DBPATH]) {
[fileManager copyItemAtPath:[[NSBundlemainBundle]pathForResource:@"word"ofType:@"db"]toPath:DBPATHerror:nil];
}
计算手机磁盘剩余空间的大小
NSDictionary *systemAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil];
NSString *diskFreeSize = [systemAttributes objectForKey:@"NSFileSystemFreeSize"];
NSLog(@"可用空间:%.2f GB", [diskFreeSize floatValue]/1024/1024/1024);