无法从iOS中的sqlite数据库中删除表

时间:2016-05-21 06:26:49

标签: ios iphone sqlite sql-delete appdelegate

我在AppDelegate类的方法applicationDidEnterBackground中编写了删除查询。但是当我停止模拟器时它不会删除数据库表。我想在应用程序在后台输入或应用程序终止时删除数据库表。这是删除表查询的- (void)applicationDidEnterBackground:(UIApplication *)application { sqlite3 *database; NSArray * dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* docsDir = [dirPaths objectAtIndex:0]; NSString * databasePath = [docsDir stringByAppendingPathComponent:@"sssw.sqlite"]; if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { NSString *sqlStatement_userInfo =[NSString stringWithFormat:@"DELETE * from SHOPDATA"]; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, [sqlStatement_userInfo UTF8String], -1, &compiledStatement, NULL) == SQLITE_OK) { NSLog(@"table deleted"); } else { NSLog(@"Unable to delete table"); } sqlite3_finalize(compiledStatement); } sqlite3_close(database); } 方法。

HAVING

请告诉我该怎么做以及我在这里做错了什么。 任何帮助将不胜感激。

0 个答案:

没有答案
相关问题