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;

相关推荐
江上清风山间明月6 天前
如何让APK获得系统权限
android·apk·root·系统权限
tanqth8 天前
Delphi跨平台开发中为Linux开发的优劣分析
跨平台·delphi·分析·linux开发
霍格沃兹_测试10 天前
软件测试 | 测试开发 | APK 逆向工程 - 解析 apk 基本信息和方法调用图
apk
pcplayer1 个月前
Delphi 结构体序列化为二进制串
delphi
BillKu2 个月前
在 Delphi 5 中获取 Word 文档页数的方法
word·delphi
BillKu2 个月前
Delphi 5 中操作 Word 表格时禁用鼠标交互
word·delphi
看那山瞧那水2 个月前
DELPHI 利用OpenSSL实现加解密,证书(X.509)等功能
delphi·openssl
lincats3 个月前
一步一步学习使用FireMonkey动画(6) 用实例理解动画的运行状态
ide·delphi·livebindings·delphi 12.3·firemonkey
lincats3 个月前
一步一步学习使用FireMonkey动画(3) 使用Delphi的基本动画组件类
ide·delphi·delphi 12.3·firemonkey
lincats3 个月前
一步一步学习使用FireMonkey动画(1) 使用动画组件为窗体添加动态效果
android·ide·delphi·livebindings·delphi 12.3·firemonkey