Database file not showing on the device
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Database file not showing on the device
The database connection is lost when I am testing the app on my iPad.
My app is a quiz with questions and answer. The question does not come up at all on the iPad.
What am I doing wrong? Where in the standalone setup do I have to mention there is a database file SqlLite ?
Thanks for any help.
My app is a quiz with questions and answer. The question does not come up at all on the iPad.
What am I doing wrong? Where in the standalone setup do I have to mention there is a database file SqlLite ?
Thanks for any help.
Re: Database file not showing on the device
The database needs to be copied to the app's documents directory. Include it in the binary and copy it to the device on first launch.
Gerry
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Database file not showing on the device
To elaborate, when you build the app binary have the database file in the Copy Files pane of the Standalone Application Settings for the app. That'll copy it to the binary. Then, in your openstack script, have something like this:
Obviously you need to replace the file name "database.sqlite" with whatever the actual name of your database is.
Gerry
Code: Select all
on openstack
if the environment = "mobile" then
if there is not a file (specialFolderPath("Documents") & "/database.sqlite") then
put (specialFolderPath("engine") & "/database.sqlite") into spath
put url ("binfile:" & spath) into dpath
put dpath into url ("binfile:"& (specialFolderPath("Documents") & "/database.sqlite"))
end if
end if
-- open the database here
end openstack
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Database file not showing on the device
In File -> Standalone Application Settings... there is a Copy Files section that permit you to specify what files or folder to copy relative to your application.
However for security reasons, I don't think that you can copy external app files on iOS. I suggest you to incorporate your sqlite file as a custom properties like explained in this page: http://livecode.wikia.com/wiki/Loading, ... inary_file
then you may write the file in the device and use it.
I suppose that iOS, like Android, reserve a virtual folder to applications; this way they can't hurt the device.
However for security reasons, I don't think that you can copy external app files on iOS. I suggest you to incorporate your sqlite file as a custom properties like explained in this page: http://livecode.wikia.com/wiki/Loading, ... inary_file
then you may write the file in the device and use it.
I suppose that iOS, like Android, reserve a virtual folder to applications; this way they can't hurt the device.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Database file not showing on the device
Moderation note: a duplicate of this thread in "Complete Beginners" was merged with this topic.
Going forward, please make only one thread per topic so those who might be able to help can know where to do so, and others who would find the topic useful can find the answers in one place. Thanks.
Going forward, please make only one thread per topic so those who might be able to help can know where to do so, and others who would find the topic useful can find the answers in one place. Thanks.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Database file not showing on the device
Gerry,
Thanks for the codes to access the database on mobile. In fact, I was able to connect to the database but when it gets to read the table, I receive this error : revdberr, Database Error: No such table Histoire" The table "Histoire" does exist and it has records in it.
Here are the codes to open the database:
# Open the database
put "/users/frantzcharles/Documents/All About LiveCode/Cric-Crac/CricCracDB.sqlite" into thePath
put "/CricCracDB.sqlite" into theMobilePath
if the environment = "mobile" then
if there is not a file (specialFolderPath("Documents") & theMobilePath) then
put (specialFolderPath("engine") & theMobilePath) into sPath
put url ("binfile:" & sPath) into dPath
put dPath into url ("binfile:" & (specialFolderPath("Documents") & theMobilePath))
end if
put (specialFolderPath("Documents") & "/CricCracDB.sqlite") into tDBPath
put revOpenDatabase("sqlite", tDBPath ,,,,,,) into tConID
else
## this is not mobile
put revOpenDatabase("sqlite", thePath ,,,,,,) into tConID
end if
Here are the codes to access the table
put "Select Hist_Question from Histoire where Hist_Id = " & tNextQ into tSQL
put revdb_querylist(,,g_ConID, tSQL) into tList
Do I need to do something with the table before I can read from it?
Thanks for your help.
Fanix
Thanks for the codes to access the database on mobile. In fact, I was able to connect to the database but when it gets to read the table, I receive this error : revdberr, Database Error: No such table Histoire" The table "Histoire" does exist and it has records in it.
Here are the codes to open the database:
# Open the database
put "/users/frantzcharles/Documents/All About LiveCode/Cric-Crac/CricCracDB.sqlite" into thePath
put "/CricCracDB.sqlite" into theMobilePath
if the environment = "mobile" then
if there is not a file (specialFolderPath("Documents") & theMobilePath) then
put (specialFolderPath("engine") & theMobilePath) into sPath
put url ("binfile:" & sPath) into dPath
put dPath into url ("binfile:" & (specialFolderPath("Documents") & theMobilePath))
end if
put (specialFolderPath("Documents") & "/CricCracDB.sqlite") into tDBPath
put revOpenDatabase("sqlite", tDBPath ,,,,,,) into tConID
else
## this is not mobile
put revOpenDatabase("sqlite", thePath ,,,,,,) into tConID
end if
Here are the codes to access the table
put "Select Hist_Question from Histoire where Hist_Id = " & tNextQ into tSQL
put revdb_querylist(,,g_ConID, tSQL) into tList
Do I need to do something with the table before I can read from it?
Thanks for your help.
Fanix
Re: Database file not showing on the device
I would prefer to use:
Code: Select all
put revDataFromQuery(tab,return,connID,tSQL) into tList
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Database file not showing on the device
(specialFolderPath("Documents") & theMobilePath)
for mobile should be;
(specialFolderPath("documents") & theMobilePath)
Case sensitive.
Simon
for mobile should be;
(specialFolderPath("documents") & theMobilePath)
Case sensitive.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Database file not showing on the device
The default delimiters for DB access are TAB and CR, so if you leave these 2 paramsI would prefer to use:Code: Select all
put revDataFromQuery(tab,return,connID,tSQL) into tList
it will still work as exspected with TAB and CR

Re: Database file not showing on the device
Yes, iOS and Android have case sensitive file systems,(specialFolderPath("Documents") & theMobilePath)
for mobile should be;
(specialFolderPath("documents") & theMobilePath)
Case sensitive.
but this is a Livecode script, so that doesn't matter

Re: Database file not showing on the device
Have I lost the plot again?but this is a Livecode script, so that doesn't matter

Isn't the problem on iPad? I'm guessing it works on desktop.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Database file not showing on the device
This also works on mobile, Simon, no matter HOW you spell "documenTs" 

Re: Database file not showing on the device
I am so not keeping up with the times
Anyway;
Hi Fanfanix,
When I read the line from the dictionary that said something like "if there is not a database by that name liveCode will create one..." I thought that was really cool! Well I don't think it's cool anymore. sure you can connect to a database, but a new one, and you'll never be told until you get the "revdberr".
Simon

Anyway;
Hi Fanfanix,
In fact, I was able to connect to the database but when it gets to read the table, I receive this error : revdberr, Database Error: No such table Histoire"
When I read the line from the dictionary that said something like "if there is not a database by that name liveCode will create one..." I thought that was really cool! Well I don't think it's cool anymore. sure you can connect to a database, but a new one, and you'll never be told until you get the "revdberr".
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Database file not showing on the device
Your problem may be the line:
put url ("binfile:" & sPath) into dPath
You don't have a variable sPath, but you do have one called thePath that you set up at the start of your script. Perhaps try fixing that?
put url ("binfile:" & sPath) into dPath
You don't have a variable sPath, but you do have one called thePath that you set up at the start of your script. Perhaps try fixing that?
Re: Database file not showing on the device
Nostrongbow wrote:Your problem may be the line:
put url ("binfile:" & sPath) into dPath
You don't have a variable sPath, but you do have one called thePath that you set up at the start of your script. Perhaps try fixing that?

...
## thePath is obviously only used on the DESKTOP
put "/users/frantzcharles/Documents/All About LiveCode/Cric-Crac/CricCracDB.sqlite" into thePath
put "/CricCracDB.sqlite" into theMobilePath
if the environment = "mobile" then
if there is not a file (specialFolderPath("Documents") & theMobilePath) then
put (specialFolderPath("engine") & theMobilePath) into sPath
## These two lines are also correct!
put url ("binfile:" & sPath) into dPath
put dPath into url ("binfile:" & (specialFolderPath("Documents") & theMobilePath))
end if
put (specialFolderPath("Documents") & "/CricCracDB.sqlite") into tDBPath
put revOpenDatabase("sqlite", tDBPath ,,,,,,) into tConID
else
## this is not mobile
put revOpenDatabase("sqlite", thePath ,,,,,,) into tConID
end if
...
But everything else looks OK!?
No idea why that does not work...
I am sure it is one of these obvious "OMG! slap on the forehead" things!
