zoukankan      html  css  js  c++  java
  • 获取iPhone通话记录(需越狱)

    转自http://www.cnblogs.com/ydhliphonedev/archive/2011/10/13/2210435.html

    越狱后的手机的数据库文件可以自由访问,通话记录通常保存在call_History.db这个文件中.只要读取这个文件,我们就能知道目前手机的通话记录了

    下面这段代码检测手机是否能读取到Call_History.db

     
    1. NSFileManager *fileManager = [NSFileManager defaultManager];  
    2. NSDirectoryEnumerator *dirnum = [[NSFileManager defaultManager] enumeratorAtPath: @"/private/"];  
    3. NSString *nextItem = [NSString string];  
    4. while( (nextItem = [dirnum nextObject])) {  
    5.     if ([[nextItem pathExtension] isEqualToString: @"db"] ||  
    6.         [[nextItem pathExtension] isEqualToString: @"sqlitedb"]) {  
    7.         if ([fileManager isReadableFileAtPath:nextItem]) {  
    8.             NSLog(@"%@", nextItem);  
    9.         }  
    10.     }  
    11. }  

    通常发现的文件位置为var/wireless/Library/CallHistory/call_history.db,ios3和4可能不同,具体看上面代码打印的结果.

    下面这段代码可以读出数据库中的内容,具体怎样显示自己定制把.


    1. - (void)readCallLogs  
    2. {  
    3.     if (_dataArray == nil) {  
    4.         _dataArray = [[NSMutableArray alloc] init];  
    5.     }  
    6.     [_dataArray removeAllObjects];  
    7.     NSFileManager *fileManager = [NSFileManager defaultManager];  
    8.     NSString *callHisoryDatabasePath = @"var/wireless/Library/CallHistory/call_history.db";  
    9.     BOOL callHistoryFileExist = FALSE;  
    10.     callHistoryFileExist = [fileManager fileExistsAtPath:callHisoryDatabasePath];  
    11.     [fileManager release];  
    12.     //NSMutableArray *callHistory = [[NSMutableArray alloc] init];  
    13.       
    14.     if(callHistoryFileExist) {  
    15.         if ([fileManager isReadableFileAtPath:callHisoryDatabasePath]) {  
    16.             sqlite3 *database;  
    17.             if(sqlite3_open([callHisoryDatabasePath UTF8String], &database) == SQLITE_OK) {  
    18.                 sqlite3_stmt *compiledStatement;  
    19.                 NSString *sqlStatement = [NSString stringWithString:@"SELECT * FROM call;"];  
    20.                   
    21.                 int errorCode = sqlite3_prepare_v2(database, [sqlStatement UTF8String], -1,  
    22.                                                    &compiledStatement, NULL);  
    23.                 if( errorCode == SQLITE_OK) {  
    24.                     int count = 1;  
    25.                       
    26.                     while(sqlite3_step(compiledStatement) == SQLITE_ROW) {  
    27.                         // Read the data from the result row  
    28.                         NSMutableDictionary *callHistoryItem = [[NSMutableDictionary alloc] init];  
    29.                         int numberOfColumns = sqlite3_column_count(compiledStatement);  
    30.                         NSString *data;  
    31.                         NSString *columnName;  
    32.                           
    33.                         for (int i = 0; i < numberOfColumns; i++) {  
    34.                             columnName = [[NSString alloc] initWithUTF8String:  
    35.                                           (char *)sqlite3_column_name(compiledStatement, i)];  
    36.                               
    37.                             data = [[NSString alloc] initWithUTF8String:  
    38.                                     (char *)sqlite3_column_text(compiledStatement, i)];  
    39.                               
    40.                               
    41.                                 }   
    42.                             [callHistoryItem setObject:data forKey:columnName];  
    43.                               
    44.                             [columnName release];  
    45.                             [data release];  
    46.                         }  
    47.                         [_dataArray addObject:callHistoryItem];  
    48.                         [callHistoryItem release];  
    49.                         count++;  
    50.                     }  
    51.                 }  
    52.                 else {  
    53.                     NSLog(@"Failed to retrieve table");  
    54.                     NSLog(@"Error Code: %d", errorCode);  
    55.                 }  
    56.                 sqlite3_finalize(compiledStatement);  
    57.             }  
    58.         }  
    59.     }   
    60.     NSLog(@"%@",_dataArray);  
    61. }  

    到此,你就可以读出所有的通话记录了.

  • 相关阅读:
    数据安全:1.98亿购车者的购车记录公之于众
    【作者面对面问答】包邮送《Redis 5设计与源码分析》5本
    关于区块链学习资料
    《机器学习》周志华西瓜书学习笔记(九):聚类
    Bulletproof零知识证明
    数据接收合并
    数据接收合并
    数据接收合并
    数据接收合并
    Tomcat 8 Host-Manager配置访问的方法,全网唯一正确配置
  • 原文地址:https://www.cnblogs.com/jiangshiyong/p/3062270.html
Copyright © 2011-2022 走看看