Rajat
Rajat

Reputation: 47

Button Click - Copy file from APK Package to Android Path. But How?

Im trying to create a simple application which will copy a file from "assets" folder of the APK Package to (e.g. mnt/sdcard/android/data/com.testdev.testapp when button1 get clicked.

But i don't know how to do this. Is this even Possible or are there any workarounds?

Could anyone help me?

Thanks in advance

Upvotes: 0

Views: 227

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007266

Step #1: Call getAssets() on any Context (e.g., your Activity) to get an AssetManager.

Step #2: Call open() on the AssetManager to get an InputStream on your desired asset.

Step #3: Use standard Java file I/O to copy from that InputStream to a FileOutputStream pointing at a spot on external storage.

Upvotes: 1

Related Questions