0

I want copy a folder to 'sdcard' with all files and folders. How do I put all the files in the exact path?(foler1/file1.txt,...file4.txt),(foler2/file1.txt,...file4.txt),...

enter image description here

by this following code I can to copy files to sdcard that exists in specific folder in 'assets' (sdcard/foldr/subfolder1/file1.txt....file4.txt) but I want copy all files and folder in sdcard.

  AssetManager assetManager = getAssets();
    String[] files = null;
    try {
        files = assetManager.list("Files");
    } catch (IOException e) {
        Log.e("tag", e.getMessage());
    }

    for(String filename : files) {
        System.out.println("File name => "+filename);
        InputStream in = null;
        OutputStream out = null;
        try {
          in = assetManager.open("Files/"+filename);   // if files resides inside the "Files" directory itself
          out = new FileOutputStream(Environment.getExternalStorageDirectory().toString() +"/" + filename);
          copyFile(in, out);
          in.close();
          in = null;
          out.flush();
          out.close();
          out = null;
        } catch(Exception e) {
            Log.e("tag", e.getMessage());
        }

can someone help me?

0 Answers0