0

I have an app pulling information from a SQLite database. It works perfectly on the iPhone Simulator, but I don't get anything when I test on a device. Are there differences to using a database between the two? I've tried looking all over and can't find anything that is helping. I see this problem is common on google, I just haven't found a solution thats worked for me.

I have put break points in and tried to debug this, on the actual device it never gets passed while (sqlite3_step(statement) == SQLITE_ROW), it is always returning SQLITE_DONE. I can't figure out why this would change on a device. Any help would be appreciated, advice on SQLite, or if the code could be improved etc. Thanks.

NSString *qsql = @"SELECT Distinct State FROM School";
    sqlite3_stmt *statement;

    if (sqlite3_prepare_v2(db, [qsql UTF8String], -1, &statement, nil) == SQLITE_OK) 
    {
        while (sqlite3_step(statement) == SQLITE_ROW) 
        {
            char *colState = (char *) sqlite3_column_text(statement, 0);
        NSString *state = [[NSString alloc] initWithUTF8String:colState];

        [states addObject:state];
        [state release];
    }
    sqlite3_reset(statement);
}
return states;

}

sasquatch
  • 285
  • 2
  • 13

1 Answers1

1

The first thing that comes to mind is that the database is installed properly on the simulator but not on the phone.

Check out this answer to see if it helps you.

Community
  • 1
  • 1
DVG
  • 17,392
  • 7
  • 61
  • 88