sqlite file path problem

hi bro
i have create Database by my seilf and i post it in system.DecmountDirectory and it work prefctly on corona smilutor 
but after i build it, On android device it give me error !
how can i solve it ?

some part of my code 
 

 local path =system.pathForFile("data.db",system.DocumentsDirectory)  db=sqlite3.open(path) for row in db:nrows ("SELECT\*FROM morning") do

the result on device 

How do you create the database in system.DocumentsDirectory?  You have to initialize the database somehow. If you have the sqlite database in the folder with your main.lua, that’s system.ResourcesDirectory and it’s read-only.

It’s your responsibility to copy/initialize your database in a writable area like system.DocumentsDirectory.  Installing your apk file to your android device does not include your Corona simulator’s sandbox folders.

Rob

I created by SQLite browser app
Then I posted in Decument By file-sandbox by simulator

So what I need to do after posted in same file of main.lua
And I changed file path to resource
It also give me error with different reason
See the attached file

You have to install your initial SQLite database in your project alongside your main.lua. Then you need to detect if this is the first time the app is starting (perhaps by checking to see if the SQLite database is in system.DocumentsDirectory. If you don’t find it there, then you need to use the file IO functions to open the SQLite file in system.ResourceDirectory for read in binary mode, read it in, then open a file for writing in system.DocumentsDirectory in binary mode and write the data out, close both files, and then use the sqlite.* function to open the database in system.DocumentsDirectory.

Now for the second error, are you doing anything with widget.newButton()?

Rob

Yes I have 3 buttons

About the SQLite file , I want to make it read just.what I need to do ? Just posted at main.lua file !!?

Put it in the same folder as main.lua and open it from system.ResourceDirectory.

Ok thank you.
I have solved the other problem. The other problem cursed name of image was with underscore not allowing with android
‘morning_activeButton ‘
I have changed to duch
‘morning-activeButton’ and it work fine

How do you create the database in system.DocumentsDirectory?  You have to initialize the database somehow. If you have the sqlite database in the folder with your main.lua, that’s system.ResourcesDirectory and it’s read-only.

It’s your responsibility to copy/initialize your database in a writable area like system.DocumentsDirectory.  Installing your apk file to your android device does not include your Corona simulator’s sandbox folders.

Rob

I created by SQLite browser app
Then I posted in Decument By file-sandbox by simulator

So what I need to do after posted in same file of main.lua
And I changed file path to resource
It also give me error with different reason
See the attached file

You have to install your initial SQLite database in your project alongside your main.lua. Then you need to detect if this is the first time the app is starting (perhaps by checking to see if the SQLite database is in system.DocumentsDirectory. If you don’t find it there, then you need to use the file IO functions to open the SQLite file in system.ResourceDirectory for read in binary mode, read it in, then open a file for writing in system.DocumentsDirectory in binary mode and write the data out, close both files, and then use the sqlite.* function to open the database in system.DocumentsDirectory.

Now for the second error, are you doing anything with widget.newButton()?

Rob

Yes I have 3 buttons

About the SQLite file , I want to make it read just.what I need to do ? Just posted at main.lua file !!?

Put it in the same folder as main.lua and open it from system.ResourceDirectory.

Ok thank you.
I have solved the other problem. The other problem cursed name of image was with underscore not allowing with android
‘morning_activeButton ‘
I have changed to duch
‘morning-activeButton’ and it work fine