Delphi 打包文件到APK安装包中

打包文件到APK安装包中

目的:将配置文件或SQLITE打包进APK中

1.首先,打开菜单 Project - Deployment

2.点击添加按钮,选择要添加的文件(文件最好放在工程目录中,这样,即使该工程在其他电脑上打开,也能找到该文件)

3.修改Remote Path:

当开发Android程序时,Remote Path修改为 assets\internal\

当开发iOS程序时,Remote Path修改为 StartUp\Documents

Remote Path说明

Remote Path写入assets\internal\或assets\就可以

其中assets\internal\会把文件发布到TPath.GetDocumentsPath(也就是/data/data/.../files)目录下

assets\会把文件发布到TPath.GetSharedDocumentsPath(也就是/mnt/sdcard/Android/data/.../files)目录下。

4.程序中使用文件的方法:

首先,需要引用 System.IOUtils 文件,这样才能使用TPath类

TPath.Combine(TPath.GetDocumentsPath,'a.htm')

TPath.GetDocumentsPath + PathDelim + 'a.htm'

获取文件的绝对路径,然后就可以使用这个路径对文件进行操作了。

打包SQLITE

在fdconnection的beforconnect事件中填写如下代码:

procedure TForm1.FDConnection1BeforeConnect(Sender: TObject);

begin

FDConnection1.Params.Values['Database'] := TPath.Combine(TPath.GetDocumentsPath, 'test.s3db');

end;

相关推荐
lincats2 天前
一步一步学习使用LiveBindings(14)TListView进阶使用(2),打造天气预报程序
delphi·livebindings·delphi 12.3·firedac·firemonkey·tlistview
lincats3 天前
一步一步学习使用LiveBindings(13) TListView的进阶使用(1)
delphi·livebindings·delphi 12.3·firemonkey·tlistview
lincats4 天前
一步一步学习使用LiveBindings(12) LiveBindings与具有动态呈现的TListView
delphi·livebindings·delphi 12.3·firemonkey
chilavert3185 天前
技术演进中的开发沉思-62 DELPHI VCL系列:VCL下的设计模式
开发语言·delphi
lincats6 天前
一步一步学习使用LiveBindings(11) 绑定到自定义外观的ListBox
list·delphi·delphi 12.3·firedac·firemonkey·tlistview
lincats7 天前
# 一步一步学习使用LiveBindings(10) LiveBindings绑定到漂亮的TCombobox
ide·delphi·livebindings·delphi 12.3
lincats8 天前
一步一步学习使用LiveBindings(9) LiveBindings图像绑定与自定义绑定方法(2)
delphi·livebindings·delphi 12.3·firedac·firemonkey
lincats10 天前
一步一步学习使用LiveBindings(8) 使用向导创建用户界面,绑定格式化入门
delphi·livebindings·delphi 12.3·firedac·firemonkey
lincats14 天前
一步一步学习使用LiveBindings(7) 实现对JSON数据的绑定
android·delphi·livebindings·delphi 12.3·firedac
lincats15 天前
一步一步学习使用LiveBindings(6) 实现Master-Detail主从关系的绑定
delphi·livebindings·delphi 12.3·firedac·firemonkey