I can receive the data from .sql file(sqlite) in iOS5 , But in ios6. The app is getting hang..
If the query is select * from Table then works perfectly
If query is select *from Table order by ID DESC then the app is getting hang
some times the app hang in (sqlite3_open([dbPath UTF8String],&db) == SQLITE_OK)
some times hangs in
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
}
Finalize the statements and Close the connection properly each you perform an operation, then you should be fine with the sqlite. If the statements are not finalized then you get to states like SQLITE_BUSY,SQLITE_LOCKED which you need to handle. If the app is hanging that means your main thread is blocked. Following is a sample sqlite operation.
-(int)keyIdForImgId:(int)ImgId { @synchronized(self) { int keyId=0; sqlite3 *database=nil; if (sqlite3_open([[self getDBPath] UTF8String], &database) == SQLITE_OK) { const char *sql = "SELECT keyId From SomeTableName WHERE imageId=?"; sqlite3_stmt *selectstmt=nil; if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) { sqlite3_bind_int(selectstmt, 1, ImgId); while(sqlite3_step(selectstmt) == SQLITE_ROW) { keyId = sqlite3_column_int(selectstmt, 0); } } sqlite3_finalize(selectstmt); sqlite3_close(database); } return keyId; } }