The Ticked Off application is the sample used in the getting started series...
http://www.runrev.com/developers/docume ... rs-course/ - under # 6 if you download the materials, there is completed stack. It's a task list. I used it as a base for one of the cards of my app. Anyway, when I test it on my android, it works - you can add and delete tasks. But when I try my app, it doesn't. Makes no sense.
However, moving on...
First, I added my database in the standalone application settings. That seemed to have worked a bit - because now when I open the application, the data appears.
Unfortunately, it still won't access the database - either to read or to write. It doesn't seem to understand specialfolderpath(26)...(nor did it understand specialfolderpath("documents")) - it just shows ""/files/tasks.sqlite"....and skips the part about specialfolderpath. Because it can't find the database, it is always trying to create a new one - unsuccessfully.
My database is tasks.sqlite
Code: Select all
on preOpenStack
## Connect to the database
## Files that you add via the "copy files" tab in the standalone builder can be found in hte specialfolder("engine") on iOS
put specialfolderpath("engine") & "/tasks.sqlite" into tHiScoreFile
put specialfolderpath(26) & "/files/tasks.sqlite" into tHiScoreFileUser
## No suffix neccessary, but won't hurt of course :-)
## Check if the files have already been copied before, if not, copy them:
if there is NOT a file tHiScoreFileUser then
answer tHiScoreFile
answer tHiScoreFileUser
put url("binfile:" & tHiScoreFile) into url("binfile:" & tHiScoreFileUser)
end if
answer "try"
when I run this, tHiScoreFile is: data/app/com.runrev.disaster_app_1.apk/tasks.sqlite
tHiScoreFilerUser is /files/tasks.sqlite (skipping whatever specialfolderpath(26) is..)
...which doesn't work...I don't know how specialfolderpath(26) fits it...or what it is... or how to create it.
Bottom line, I don't get it.
Just for the record...here are the codes I am using to access the database and writing to it:
Code: Select all
on databaseConnect
local tDatabasePath, tDatabaseID
## The database must be in a writeable location
put specialFolderPath(26) & "/tasks.sqlite" into tDatabasePath
## Open a connection to the database
## If the database does not already exist it will be created and we will add the table
if there is not a file tDatabasePath then
## Store the database id as a custom property so other handlers can access it
set the cDatabaseID of me to tDatabaseID
databaseCreateTable
else
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id as a custom property so other handlers can access it
set the cDatabaseID of me to tDatabaseID
end if
put the cDatabaseID of me into tbob
answer tbob
answer tDatabaseID
end databaseConnect
(when I run the code above,and use "documents" instead of 26, I get 1for tbob - but that doesn't help me because no data appears and I can't add data.
when I use 26, I get a blank for tbob)
Code: Select all
on addTask pTaskID, pTitle, pKind
put the short name of the current card into tusename
put "INSERT into tasks VALUES ('" & pTaskID & "','" & pTitle & "','', 'false','" & tusename & "','','" & pKind & "')"into tusethis
revExecuteSQL the cDatabaseID of me, tusethis
put "SELECT count(*) from tasks" into tSQL
put revDataFromQuery(,,the cDatabaseID of me,tSQL) into tDetails
return tDetails
end addTask