1

It's possible to add external content (for example a Zip that contains maps) to an Android Project and at the first start of the application move it to storage/emulated/0 or /sdcard/ or another generic path? How?

1
  • You can add it to the assets folder and on app start you can copy the content to a directory on the phone. Jan 26, 2016 at 15:17

1 Answer 1

2

You can put your zip file in the assets folder, then make a validation of if the file exists already in your generic path, if there is not then start with the copy.

To create your assets folder in Android Studio:

Right click your app folder from the Android view > New > New Folder > Assets folder > Press finish.

Paste your zip file there, and it will be contained in your next generated apk file.

In this question, Nermeen provides a good way to access the files in your assets folder, here is the code:

This will list all the files in the assets folder:

AssetManager assetManager = getAssets(); 
String[] files = assetManager.list(""); 

This to open a certian file:

InputStream input = assetManager.open(assetName);

Then you can check if the file has already been copied, or not. You can check any of the following answers to do it.

How to copy files from 'assets' folder to sdcard?

Copy directory from Assets to local directory

Not the answer you're looking for? Browse other questions tagged or ask your own question.