Problem with Sqlite - Select

Hi all. I created a simple database and I’m trying to find it that way.

In simulator is everything ok, but on phone the program stops the search without notice any error.

Text “Test is DONE” is not displayed in the console. But application further works.

What am I doing wrong ?

 local path = system.pathForFile( "userdata.db", system.DocumentsDirectory ) local db = sqlite3.open( path ) if fileExist("userdata.db") then print ("database is open") flg = false sel = [[SELECT \* FROM test WHERE user\_id = ']]..t["user\_id"]..[[';]] for row in db:nrows(sel) do flg = true end print ("Test is DONE") end

Can you try this instead?
 

  local json = require("json")   local path = system.pathForFile( "userdata.db", system.DocumentsDirectory )   local db = sqlite3.open( path )     if db then      print ("database is open")    flg = false    sel = [[SELECT \* FROM test WHERE user\_id = ']]..t["user\_id"]..[[';]]    for row in db:nrows(sel) do            print( json.prettify( row ) )      flg = true       end    print ("Test is DONE")   else    print ("Database failed to open")   end

and see what you get printed in the console

Hi Rob. I try it, but nothing new. In console is only “database is open”. Json and “Test is done” not.
But in simulator is all ready… :frowning:

How are you populating your database? This is an area were people run into problems. Your app has to initialize the database in system.DocumentsDirectory and pre-populate it with any values that you need. Some people will ship their app with a copy of the pre-populated database in system.ResourceDirectory, but since that’s a Read Only resource, you have to copy that database to system.DocumentsDirectory before you can use it. 

No, I create a database on the fly and store data I type in application. Where is database in android phone ? I can not find in phone folders.

Even after reinstalling the app reports that the database is found - I want to completely delete

Can you post your database creation and initialization code?

Thanks

Rob

Can you try this instead?
 

  local json = require("json")   local path = system.pathForFile( "userdata.db", system.DocumentsDirectory )   local db = sqlite3.open( path )     if db then      print ("database is open")    flg = false    sel = [[SELECT \* FROM test WHERE user\_id = ']]..t["user\_id"]..[[';]]    for row in db:nrows(sel) do            print( json.prettify( row ) )      flg = true       end    print ("Test is DONE")   else    print ("Database failed to open")   end

and see what you get printed in the console

Hi Rob. I try it, but nothing new. In console is only “database is open”. Json and “Test is done” not.
But in simulator is all ready… :frowning:

How are you populating your database? This is an area were people run into problems. Your app has to initialize the database in system.DocumentsDirectory and pre-populate it with any values that you need. Some people will ship their app with a copy of the pre-populated database in system.ResourceDirectory, but since that’s a Read Only resource, you have to copy that database to system.DocumentsDirectory before you can use it. 

No, I create a database on the fly and store data I type in application. Where is database in android phone ? I can not find in phone folders.

Even after reinstalling the app reports that the database is found - I want to completely delete

Can you post your database creation and initialization code?

Thanks

Rob