簡體   English   中英

從 iOS4 上的 call_history.db 中刪除行

[英]delete row from call_history.db on iOS4

我正在嘗試從 call_history.db 中刪除行。 我可以在數據庫中讀取,我發現我必須取消的行但是當我 go 啟動查詢以刪除它時,它什么也不做,我刪除了這些值,但是如果我嘗試使用相同的查詢通過 SSH 連接到數據庫工作正常。 我指定我正在使用越獄 iPhone,並且我的應用程序位於 / Applications 文件夾中,然后不在沙箱中。 這是我使用的代碼

strPhone 是電話號碼字符串

data * provaData1 = [[data alloc] init];
    NSString * queryPhone = [[NSString alloc] initWithFormat:@"DELETE FROM call WHERE address LIKE '%%%@%%'", strPhone];
    [provaData1 eliminaValoriDaDB:@"" :queryPhone withPath:@"var/wireless/Library/CallHistory/call_history.db"];

“數據”實現是這樣的

- (void)eliminaValoriDaDB:(NSString *)number :(NSString *)sqlString withPath:(NSString *)dbPath {
//NSString *dbPath=@"/User/Library/SMS/sms.db";

 if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) 
 {
    if(delStmt == nil) 
    {
        const char *sql = [sqlString UTF8String];
        //const char *sql = [sqlDel UTF8String];
        if(sqlite3_prepare_v2(database, sql, -1, &delStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating del statement. '%s'", sqlite3_errmsg(database));
    }
    if (![number isEqualToString:@""]) 
    {
        sqlite3_bind_int(delStmt, 1, [number intValue]);
    }

    if (SQLITE_DONE!= sqlite3_step(delStmt)) {
        NSAssert1(0, @"Error while deleting. '%s'", sqlite3_errmsg(database));


    }
    sqlite3_reset(delStmt);
    delStmt = nil;


  }
 else
    NSLog(@"error db not open");
    sqlite3_close(database);}

請幫幫我....我不知道該怎么辦謝謝安德里亞

NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
    NSArray *subPaths = [fileManager subpathsAtPath:@"/private/var/wireless/Library/CallHistory"];
    for (NSString *aPath in subPaths) {
        BOOL isDirectory;
        [fileManager fileExistsAtPath:aPath isDirectory:&isDirectory];
        if (isDirectory) {

            NSDictionary *attrib = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithUnsignedLong:775], NSFilePosixPermissions, nil ];


            NSError *error = nil;
            [fileManager setAttributes:attrib ofItemAtPath:aPath error:error];
            if (error) 
            {
                NSLog(@"error: %@", error);
            }
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM