I am trying to copy a SQlite file from my prepackaged app to the docs folder on my iPhone. I have had no success following another example I found on the forums that was similar. This is the code that I have modified. Any ideas? The file does exist in the docs folder it just seems to be corrupt as it contains no data and is 0kb in size after being copied. Originally the file is 3kb and had some tables in it.
if the environment is "mobile" then
put (specialFolderPath("Documents") & "/System.sqlite") into tPathToDatabase
put (specialFolderPath("engine") & "System.sqlite") into tPathToStartLoc
try
if not (there is a file tPathToDatabase) then
put url ("binfile:" & tPathToStartLoc) into temp
put temp into url ("binfile:" & specialfolderpath("Documents") & "/System.sqlite")
wait 5 milliseconds with messages
end if
catch pErr
put pErr into field 1
end try
try
go stack tPathToDatabase
catch pErr
put pErr into field 1
end try
end if
put (specialFolderPath("engine") & "/db.sqlite") into tOriginPath
put url ("binfile:" & tOriginPath) into dbTemp
put dbTemp into url ("binfile:"& (specialFolderPath("Documents") & "/db.sqlite"))
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
I think it's just a simple typo. Probably your line
put (specialFolderPath("engine") & "System.sqlite") into tPathToStartLoc
is the culprit. Check the difference with the line defining tPathToDatabase. I think you're missing a slash to separate the engine folder path from the db name.
put (specialFolderPath("Documents") & "/db.sqlite") into tPathToDatabase
if there is a file tPathToDatabase then
put revOpenDatabase("sqlite", tPathToDatabase,,,,,,) into conID
put the result into temp -- for debugging
put "SQLite DB: " & specialFolderPath("documents") & "/db.sqlite" into field status-- display SQLIte flile name with path
answer information return & "Connected to: " & tPathToDatabase & return & " conID is: " & conID
else
put (specialFolderPath("engine") & "/db.sqlite") into tOriginPath
put url ("binfile:" & tOriginPath) into dbTemp
put dbTemp into url ("binfile:"& (specialFolderPath("Documents") & "/db.sqlite"))
put revOpenDatabase("sqlite", tPathToDatabase,,,,,,) into conID
put the result into temp -- for debugging
put "SQLite DB: " & specialFolderPath("documents") & "/db.sqlite" into field status-- display SQLIte flile name with path
answer information return & "Connected to: " & tPathToDatabase & return & " conID is: " & conID
end if