I have created an app in livecode that uses an sqlite database. The app connects to the database base using the following code:
on preopenstack
--Used to connect to the database when application
--first open and open the menu stack
set the itemDelimiter to " "
put item 2 of the name of the current stack into stackname
put the length of stackname into namelength
put char 2 to namelength-1 stackname into stackname
if stackname= "FoodPoisoningInvestigator" then
-- Open a connection to the database and store
--the database id into global variable so
--other handlers can access it
put the effective filename of this stack into tFolderPath
set the itemDelimiter to slash
delete last item of tFolderPath
put tFolderPath & "/mysql2.sqlite" into gDatabasePath
put revOpenDatabase("sqlite",gDatabasePath) into gDatabaseID
end if
end preopenstack
In the file setting of the standalone setting dialog I have selected the mysql2.sqlite which is added to the folder when creating windows standalone but not for android. The app installs on the mobile but it does not connect to the database even when I manually add it to the folder before installing.
What am I doing wrong?
Perhaps, yor app doesn't have permission to access the database in the apk package or gDatabasePath doesn't contain what you expect or the path doesn't exist. Note that the .apk package is a zip file, which can't be accessed directly and thus virtual paths are used. Try
put specialFolderPath("engine") & "/mysql2.sqlite" into gDatabasePath
or install the database into
specialFolderPath("documents")
and use
put specialFolderPath("documents") & "/mysql2.sqlite" into gDatabasePath