2011-08-09 110 views
2

我嘗試使用以下代碼,但無法訪問它。如何從iPhone獲取通話記錄?

NSDirectoryEnumerator *dirnum = [[NSFileManager defaultManager] enumeratorAtPath: @"/private/var/mobile/Library/"]; 

NSLog(@"DirectoryAttributes:%@",[dirnum directoryAttributes]); 

響應結果:

「DirectoryAttributes:{
NSFileCreationDate = 「2008-01-01 5點38分41秒GMT」;
NSFileExtensionHidden = 0;
NSFileGroupOwnerAccountID = 501;
NSFileGroupOwnerAccountName = mobile;
NSFileModificationDate =「2011-07-29 11:38:10 GMT」;
NSFileOwnerAccountID = 501;
NSFileOwnerAccountName = mobile;
NSFilePosixPermissions = 493;
NSFileReferenceCount = 26;
NSFileSize = 986;
NSFileSystemFileNumber = 43;
NSFileSystemNumber = 234881026;
NSFileType = NSFileTypeDirectory;
}」

幫我訪問call_history.db數據表。

感謝。

+0

[iphone「無法打開數據庫文件」for call_history.db in xcode app](http://stackoverflow.com/questions/5498291/iphone-unable-to -open-database-file-for-call-history-db-in-xcode-app) –

+0

參見[iPhone call log/history](http://stackoverflow.com/questions/6214725/iphone-call-log-歷史)和[訪問iPhone中的通話記錄歷史](http://stackoverflow.com/questions/3615240/accessing-call-log-history-in-iphone) –

回答

0

可以作爲獲取 -

BOOL callhistoryfileexist = FALSE; 

NSFileManager *fileManager = [NSFileManager defaultManager]; 


callhistoryfileexist = [fileManager fileExistsAtPath:@"/private/var/wireless/Library/CallHistory/call_history.db"]; 

[fileManager release]; 

if(callhistoryfileexist) 
{ 
    //copy it where you want it 
} 

注意:在iOS 5中無效

+0

謝謝,Saadnib。 (它的工作) – Dhaval

+1

不再適用於iOS 5。 – Sulthan

+1

@Sulthan如果你可以看到已經有一個筆記下面的答案:) – saadnib

5

您的應用程序沙箱,所以你不能訪問你的應用程序目錄以外的任何目錄。沒有可可觸摸或Objective C API的訪問通話記錄

相關問題