1

我想从 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?
4

1 回答 1

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/
于 2013-04-02T03:47:22.510 回答