我想通过iphone以编程方式拨打最后拨打的号码(或当前正在拨打电话)。我试过了
以下代码。但它会产生一个空值。
-(NSString*)lastDialledNumber {
NSString *path = @"/var/mobile/Library/Preferences/com.apple.mobilephone.plist";
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *lastDialed = [NSString stringWithFormat:@"%@", [dict valueForKey:@"DialerSavedNumber"]];
return (([lastDialed isEqualToString:@""])?@"":lastDialed);
}
How can I solve this?
答案 0 :(得分:0)
iPhone通话记录存储在“call_history.db”中,该位于以下路径:
/private/var/root/Library/CallHistory/call_history.db
There are other important databases on the iPhone, some of which are accessible and some are not. We can find that out using the following piece of code. This basically enumerates the system folder and subfolders and finds databases that are readable:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDirectoryEnumerator *dirnum = [[NSFileManager defaultManager] enumeratorAtPath: @"/private/"];
NSString *nextItem = [NSString string];
while( (nextItem = [dirnum nextObject])) {
if ([[nextItem pathExtension] isEqualToString: @"db"] ||
[[nextItem pathExtension] isEqualToString: @"sqlitedb"]) {
if ([fileManager isReadableFileAtPath:nextItem]) {
NSLog(@"%@", nextItem);
}
}
}
以下链接可以帮助您:
http://iosstuff.wordpress.com/2011/08/19/accessing-iphone-call-history/