Accessing SQLite Database on First Launch on iPad

I have a Corona application built for the iPad that uses a SQLite 3.0 database. The database is copied from the Resource directory to the Documents directory upon application start up if the database does not already exist in the Documents directory.

The application and database work fine - except for the first launch of the application after it is installed on the device. The SQL calls to SQLite returns the “no such table found” error message even though the database file exists in the Documents directory. If the application is terminated (by either using os.exit(), or by closing through the double home button method) and launched again the application works perfectly.

Note: I know I am not supposed to use os.exit. However since this is happening at the “login” screen, checking for a user and password in the database, I put it in for testing purposes to close the application quickly so I can test other things.

My question is: Why is the SQLite file not being recognized as a database with tables during the first launch after the install?

Thanks,
-Jason
[import]uid: 155454 topic_id: 28209 reply_id: 328209[/import]

How are you copying the database?

Are you possibly trying to access before it’s copied and it’s still open by some other process? [import]uid: 19626 topic_id: 28209 reply_id: 114153[/import]

It is copied correctly. The app understands the db is there and can open it, just doesn’t seem to understand there are tables within it, till the second run. [import]uid: 155454 topic_id: 28209 reply_id: 114624[/import]