android apk unpack,How to unpack some files from .apk to /data/data/<

本文探讨了如何将一个Android应用与一个需要在运行前启动的Native执行文件打包在一起,以便通过Socket通信。作者寻求解决方案,包括尝试使用AssetManager和文件I/O,但希望在安装时能自动解压。寻求无需手动写入设备内存的高效方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

My android application needs another NATIVE application executable to run before the android one, so that they can communicate through sockets. Android application has a JNI layer for handling the client-side communication.

Now i need to bundle up the native executable along with the apk file, so that when it is installed on a device it gets unzipped into either the phone memory or the memory card.

How do i do this?

I tried keeping the native executable in res/asset and in res/raw folders, but they still don't get unzipped in /data/data/ folder.

One way I could find is to use AssetManager and then with help of InputStream and OutputStream, i can write this file onto the device the first time it is run and then use it. But there is no point to write it manually on phone memory as it might eat up the memory. ( the case where if memory card is not present. )

Can anyone help me on how can i achieve this? It would be great if there is an option to unzip the necessary files automatically at the time of installation.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值