在越狱的iPhone中阅读SIM卡联系人

时间:2012-03-16 06:45:43

标签: iphone jailbreak sim-card

我正在开发一个需要从SIM中读取联系人的应用程序。 我知道使用官方Apple SDK是不可能的。 我正在为已越狱的iPhone 开发此应用程序。

我搜索了很多,但我得到的唯一答案是不可能的。

对这条道路的任何帮助都将非常感激。

1 个答案:

答案 0 :(得分:1)

NSString *addressbookDatabasePath = @"/private/var/wireless/Library/AddressBook/addressbook.db";
addressbookFileExist = [fileManager fileExistsAtPath:addressbookDatabasePath];
[fileManager release];
NSMutableArray *addressbook = [[NSMutableArray alloc] init];

if(addressbookFileExist) {
if ([fileManager isReadableFileAtPath:addressbookDatabasePath]) {
    sqlite3 *database;
    if(sqlite3_open([addressbookDatabasePath 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 *addressbookItem = [[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)];

                    [addressbookItem setObject:data forKey:columnName];

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