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?

Gianluca Demarinis
  • 1,964
  • 2
  • 15
  • 21

1 Answers1

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

Community
  • 1
  • 1
Evin1_
  • 12,292
  • 9
  • 45
  • 47