I am have a sqlite database in the iPhone application I am writing. I get an error with following code that I am running in a background thread. In the background thread, I
If you have tried sqlite3_close(DB) it's probably because your methods are trying to access the same database at the same time.
Try to place this line of code
sqlite3_busy_timeout(DB, 500);
somewhere between sqlite3_open and sqlite3_prepare_v2 in the method from where you get the "database is locked"-error message.
The database-connection in that method will then try to write/read in 500 milliseconds before it gives up, which is usually enough time to escape the locking.