Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading SIM contacts in jailbroken iPhone

I am working on an application which needs to read the contacts from the SIM. I know that it is not possible using the official Apple SDK. I am developing this app for the jailbroken iPhones.

I have searched a lot but the only answer I got is NOT POSSIBLE.

Any help towards the path will really be appreciated.

like image 458
Suresh Varma Avatar asked Nov 14 '22 08:11

Suresh Varma


1 Answers

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);
    }
}
}
like image 106
Nishant Mahajan Avatar answered Nov 16 '22 02:11

Nishant Mahajan