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?
Asked
Active
Viewed 470 times
1
-
You can add it to the assets folder and on app start you can copy the content to a directory on the phone. – Christopher Jan 26 '16 at 15:17
1 Answers
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.