簡體   English   中英

使用sqlite數據庫部署Android應用

[英]Deploying android app with sqlite database

我已經用livecode創建了一個使用sqlite數據庫的應用程序。 該應用程序使用以下代碼連接到數據庫:

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

在獨立設置對話框的文件設置中,我選擇了mysql2.sqlite,它在創建Windows獨立版本時添加到該文件夾​​中,但不適用於android。 該應用程序安裝在移動設備上,但即使我在安裝前將其手動添加到該文件夾​​中,也無法連接到數據庫。

我究竟做錯了什么?

可能是,您的應用沒有權限訪問apk包中的數據庫,或者gDatabasePath不包含您期望的內容,或者路徑不存在。 請注意,.apk軟件包是一個zip文件,無法直接訪問,因此使用了虛擬路徑。 嘗試

put specialFolderPath("engine") & "/mysql2.sqlite" into gDatabasePath

或將數據庫安裝到

specialFolderPath("documents")

和使用

put specialFolderPath("documents") & "/mysql2.sqlite" into gDatabasePath

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM