As you see, I've edited my code and instead of Log.e(...) I've written "e.printStackTrace();"
You should have left it as Log.e()
. Your problem with your previous edit was that you failed to copy and paste the whole stack trace. That is important, because the first line of the exception tells you what you did wrong:
java.io.FileNotFoundException: Files/01
Calling assetManager.list("Files")
should return a two-element array, with the strings "01"
and "02"
, representing the two subdirectories in Files/
. You then need to recursively descend into those to find the files, plus create corresponding directories in your output.
You can find sample code for this on StackOverflow, in this blog post, in this GitHub Gist, and in lots of other pages found via a Web search for android copy assets recursively
.
Also, a better location than Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyApp/Files/"
is getExternalFilesDir()
, a method available on any Context
, such as your Activity
. This not only already gives you an app-specific directory on external storage, but it is one that will be automatically deleted when the user uninstalls your app.