Do not tell me how to copy all the folders under the folders and files from the assets on the android? Or is it done like a regular Java?

  • As assets, do you mean the contents of the project / assets folder? - tifei

2 answers 2

basePath - from which, outPath - to which.

private void copyAssets(String outPath, String basePath) { InputStream inputStream; AssetManager assetManager = getAssets(); try { String[] assets = assetManager.list(basePath); for (String s: assets) { String[] tmp = assetManager.list(basePath+"/"+s); if (tmp.length > 0) { File dir = new File(outPath + "/" + s); dir.mkdir(); copyAssets(outPath + "/" + s, basePath + "/" + s); continue; } byte[] inputBuffer = new byte[1000]; int count; FileOutputStream f = new FileOutputStream(outPath + "/" + s); inputStream = assetManager.open(basePath + "/" + s); while ((count = inputStream.read(inputBuffer)) > 0) f.write(inputBuffer, 0, count); f.close(); } }catch (Exception e) { e.printStackTrace(); } } 
  • Well, yes, roughly the idea describes. And again the same mistake you have, to which I have already paid attention. - cy6erGn0m

If I understand your question correctly, then you need to look at the AssetManager