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

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

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

    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);
    }
    }
    }

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

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

    - (void)readCallLogs
    {
    if (_dataArray == nil) {
    _dataArray = [[NSMutableArray alloc] init];
    }
    [_dataArray removeAllObjects];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *callHisoryDatabasePath = @"var/wireless/Library/CallHistory/call_history.db";
    BOOL callHistoryFileExist = FALSE;
    callHistoryFileExist = [fileManager fileExistsAtPath:callHisoryDatabasePath];
    [fileManager release];
    //NSMutableArray *callHistory = [[NSMutableArray alloc] init];

    if(callHistoryFileExist) {
    if ([fileManager isReadableFileAtPath:callHisoryDatabasePath]) {
    sqlite3 *database;
    if(sqlite3_open([callHisoryDatabasePath UTF8String], &database) == SQLITE_OK) {
    sqlite3_stmt *compiledStatement;
    NSString *sqlStatement = [NSString stringWithString:@"SELECT * FROM call;"];

    int errorCode = sqlite3_prepare_v2(database, [sqlStatement UTF8String], -1,
    &compiledStatement, NULL);
    if( errorCode == SQLITE_OK) {
    int count = 1;

    while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
    // Read the data from the result row
    NSMutableDictionary *callHistoryItem = [[NSMutableDictionary alloc] init];
    int numberOfColumns = sqlite3_column_count(compiledStatement);
    NSString *data;
    NSString *columnName;

    for (int i = 0; i < numberOfColumns; i++) {
    columnName = [[NSString alloc] initWithUTF8String:
    (char *)sqlite3_column_name(compiledStatement, i)];

    data = [[NSString alloc] initWithUTF8String:
    (char *)sqlite3_column_text(compiledStatement, i)];


    }
    [callHistoryItem setObject:data forKey:columnName];

    [columnName release];
    [data release];
    }
    [_dataArray addObject:callHistoryItem];
    [callHistoryItem release];
    count++;
    }
    }
    else {
    NSLog(@"Failed to retrieve table");
    NSLog(@"Error Code: %d", errorCode);
    }
    sqlite3_finalize(compiledStatement);
    }
    }
    }
    NSLog(@"%@",_dataArray);
    }

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

    by MAC-z

  • 相关阅读:
    对“一道有趣的题目”的解答
    在Debian中使用Notify
    Debian服务器安装详细流程
    Lighttpd1.4.20源码分析之插件系统(1)plugin结构体和插件接口
    Lighttpd1.4.20源码分析之etag.c(h) HTTP/1.1中的Etag域
    Lighttpd1.4.20源码分析之bitset.c(h) 位集合的使用
    伸展树
    GCC中的弱符号与强符号
    Lighttpd1.4.20源码分析之fdevent系统(3) 使用
    Lighttpd1.4.20源码分析之插件系统(3)PLUGIN_TO_SLOT宏
  • 原文地址:https://www.cnblogs.com/ydhliphonedev/p/2210435.html
Copyright © 2011-2022 走看看