包>如何从.apk文件到/数据/数据​​/&LT解压一些文件;在安装apk文件夹? [英] How to unpack some files from .apk to /data/data/<package> folder while installing the .apk?

查看:148
本文介绍了包>如何从.apk文件到/数据/数据​​/&LT解压一些文件;在安装apk文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序需要另一个本地应用程序的可执行的Andr​​oid One之前运行,使他们可以通过socket通信。 Android应用程序有用于处理客户端通信的JNI层。

现在我需要与apk文件一起捆绑起来的本地可执行程序,这样,当它被安装在设备上它被解压​​到任何手机内存或存储卡。

我如何做到这一点?
我试图保持本机的可执行文件在res /资产和在res /文件夹的原料,但他们仍然不/数据/数据​​/文件夹解压得到

我能找到一种方法是使用AssetManager,然后用InputStream和OutputStream的帮助下,我可以将此文件运行它第一次写入到该设备,然后使用它。但没有指向它手动写在手机内存,因为它可能吃起来的内存。 (如果存储卡是哪里都不present的情况下)。

谁能帮我我如何能做到这一点?这将是巨大的,如果有在安装时会自动解压缩必要的文件的选项。


解决方案

  

我如何做到这一点?


您没有。您打开它自己的应用程序第一次运行。


  

我能找到一种方法是使用AssetManager,然后用InputStream和OutputStream的帮助下,我可以将此文件写入到设备上运行它的第一次,然后使用它。


正确的。


  

但没有指向它手动写在手机内存,因为它可能吃起来的记忆。


那你为什么想要它自动解压缩存在摆在首位?


  

这将是巨大的,如果有在安装时会自动解压缩必要的文件的选项。


没有,不好意思,这是不可能的。

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.

解决方案

How do i do this?

You don't. You unpack it yourself on first run of your application.

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.

Correct.

But there is no point to write it manually on phone memory as it might eat up the memory.

Then why did you want it automatically unpacked there in the first place?

It would be great if there is an option to unzip the necessary files automatically at the time of installation.

No, sorry, this is not possible.

这篇关于包>如何从.apk文件到/数据/数据​​/&LT解压一些文件;在安装apk文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆