Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 6: SQLite db doesn't work
    primarykey
    data
    text
    <p>I always use this code to open a sqlite db in my iPhone application, but now with iOS6 this code doesn't work. The function: sqlite3_prepare_v2 fails but I don't understand why!</p> <p>I also don't understand why if I try to change the name: "gamer.sqlite" of sqlite db with another name of an not existent file, the function: 'sqlite3_open' return again SQLITE_OK value.</p> <p>This is my code:</p> <pre><code>-(NSMutableArray*)view_table { const char *sql; NSMutableArray *content=[[NSMutableArray alloc] initWithObjects:nil]; [self msgbox:@"eseguo"]; /*elementi da visualizzare nella tabella*/ if(sqlite3_open([databasePath UTF8String],&amp;database)==SQLITE_OK) { [self msgbox:@"opened"]; sql = "SELECT * FROM list_gamer"; if (sqlite3_prepare_v2(database,sql, -1, &amp;selectstmt, NULL) == SQLITE_OK) { [self msgbox:@"query eseguita"]; while(sqlite3_step(selectstmt) == SQLITE_ROW) { [content addObject:[NSString stringWithFormat:@"%s",sqlite3_column_text(selectstmt,0)]]; } } } return content; } - (void)viewDidLoad{ NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; databasePath = [[documentsDir stringByAppendingPathComponent:@"gamer.sqlite"] copy]; if(![[NSFileManager defaultManager] fileExistsAtPath:databasePath]) { NSFileManager *fileManager = [NSFileManager defaultManager]; int success = [fileManager fileExistsAtPath:databasePath]; if(success) { [fileManager removeItemAtPath:databasePath error:nil]; return; } NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"gamer.sqlite"]; // Copy the database from the package to the users filesystem [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil]; documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); documentsDir = [documentPaths objectAtIndex:0]; } [super viewDidLoad]; } - (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; } -(IBAction)start_game:(id)sender{ self.view=frmgame; [self view_table]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload