SQL: sqlite_master crashes simulation

Hello!
I am using

db:exec([[SELECT COUNT(\*) as 'tblExists' FROM sqlite\_master]])

to check if in the db there are tables, but simulation crashes.

What I want to do is to copy a db file from recourses to documents, but only if the db file in documents is empty.
Because

local path = system.pathForFile("data.db",system.DocumentsDirectory) db = sqlite3.open( path )
creates the data.db as an empty file and overwrites the db file with data.

Any idea why it crashes or another way to do what I am trying (copy a db file from recourses to documents, but only if the db file in documents is empty)?

Thank you! [import]uid: 38658 topic_id: 16188 reply_id: 316188[/import]