tags:

views:

103

answers:

2

I have 2 binary files that i would like to package with my apk. (/res/raw)

i need to copy these 2 files to /sdcard when the application is run

how can i do this?

A: 

You need to use the AssetManager.

http://developer.android.com/intl/fr/reference/android/content/res/AssetManager.html

That will give you can InputStream that you can copy to a FileOutputStream.

CaseyB
A: 

It all depends on what your goal is by doing this.

Are you trying to be nice to the user and conserve disk space on the device by moving files to the sdcard? Or do you merely want to ensure that these files are on the sd card?

If you just want to put the files on the sdcard then you should use the AssetManager as CaseyB mentioned

If you are trying to conserve phone memory then consider distributing the apk file without the 2 raw files, and then on first run download the files from a server that you have set up. This may cause a bit of a problem due to the time needed to download the files, but some users on devices with limited memory available on the device itself will be appreciative of it.

snctln