tags:

views:

29

answers:

1

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.

A: 

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.

CommonsWare
Hi. Thanks for the reply. Wanted to do this automatically because, if memory card were present, it should unpack itself in memory card. Anyways.. Since it is not possible, i guess i will have to use AssetManager for my problem.
Puneet
@Puneet: Even if such a feature were available, it probably would not "unpack itself in memory card". `/data/data/your.package.here/` is located in the phone's internal flash regardless of where the app itself is installed.
CommonsWare