sqlite3 write permission problem on iphone 3.1.2
I'm currently working on a game for the iphone, where images are loaded from the internet and then stored in the local database so they do not have to be loaded again. This has always worked fine. Recently I created a new adhoc distribution for the testing group (the first time I created the distribution using SDK 3.1.2) and now everybody that has upgraded their iphone to 3.1.2 are no longer able to write to the database anymore, and thus have to load the images everytime from the internet. People with an iphone version lower than 3.1.2 have no problems and previously build versions (with SDK 3.1 or lower) have no problems on iphones with 3.1.2. The updates I made to the game had nothing to do with the datamanager in the game. Another strange thing is that I do not find any messages in the console using the following code:
- (void) saveImage:(NSString *)imagePath withData:(NSData *)imageData {
if (insert_image_statement == nil){
const char *sql2 = "INSERT INTO image (imagePat开发者_如何学Ch, imageData) VALUES (?, ?);";
if (sqlite3_prepare_v2(database, sql2, -1, &insert_image_statement, NULL) != SQLITE_OK) {
NSLog(@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
}
sqlite3_bind_text(insert_image_statement, 1, [imagePath UTF8String], -1, NULL);
sqlite3_bind_blob(insert_image_statement, 2, [imageData bytes], [imageData length], NULL);
int success = sqlite3_step(insert_image_statement);
if (success == SQLITE_ERROR){
NSLog(@"Error: failed to insert statement with message '%s'.", sqlite3_errmsg(database));
}
sqlite3_reset(insert_image_statement);
}
So the sqlite3 does not throw an error which could point me towards the solution of this problem. Does anybody know why with SDK 3.1.2 I do not seem to have the permission to write the data to the database?
was this issue resolved? I am having as similar problem with the Device/Release build in 3.1.2, where errors are thrown in the if(sqlite3_exec(...)); statement, but no error message is returned.
********UPDATE: a partial solution was reached by modifying the reference to include the full path on the device. Google "checkAndCreateDatabase" method for code. I still have failures in the sqlite prepare statement on the device in the 3.1.2 OS that I did not have in the simulator.**********
-(void)initializeDatabaseFunctions {
databaseName = "RowTable.db";
returnCode = sqlite3_open(databaseName, &sqlite);
NSString *dropRows = [[NSString alloc]initWithFormat:@"DROP TABLE IF EXISTS rows;"];
if(sqlite3_exec(sqlite, [dropRows UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) {
NSLog(@"Error DROP TABLE IF EXISTS rows: %s", errorMsg);
sqlite3_free(errorMsg);}
精彩评论