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;

相关推荐
故渊at3 天前
第一板块:Android 系统基石与运行原理 | 第二篇:Android 编译、打包与安装机制
android·系统架构·apk·打包·application·dalvik·android编译
_lorzl_6 天前
Delphi 10.4.2 IDE Attach to process... 到宿主进程时死锁的原因与修复
ide·delphi
安替-AnTi10 天前
厚朴 APK 搜索接口分析
python·apk·解析·taobao
昆曲之源_娄江河畔1 个月前
DBGridEh Footer的使用
前端·数据库·delphi·dbgrideh
pcplayer1 个月前
非常好用的 Excel 读写控件
excel·delphi·office
90程序员2 个月前
纯浏览器解析 APK 信息,不用服务器 | 开源了一个小工具
前端·apk
月巴月巴白勺合鸟月半2 个月前
从 Delphi 到 FMX:Borland/Embarcadero 跨平台开发三十年兴衰史
跨平台·delphi
START_GAME2 个月前
Delphi 10.3安装与辅助工具uniGUI 配置指南
delphi·delphi10.3
专注VB编程开发20年2 个月前
delphi死嗑Pascal冷门编程语言,Borland不认可 “通用多语言 IDE”,认为 “专有语言才是护城河”
开发语言·ide·delphi
专注VB编程开发20年2 个月前
Delphi 的VCL控件库无法公开给其他编程语言调用
开发语言·delphi