Android: How to create a directory on the SD Card and copy files from /res/raw to it?

后端 未结 2 1360
眼角桃花
眼角桃花 2020-12-03 12:29

I am trying to create a folder and several subdirectory within it on the SD Card... I then want to transfer files that I have stored in /res/raw to that folder... I addition

2条回答
  •  抹茶落季
    2020-12-03 13:02

    I experienced a similar problem when using mkdirs(), however because running the command:

    mkdir one/two

    fails on Linux, then the method http://download.oracle.com/javase/1.4.2/docs/api/java/io/File.html#mkdirs() subsequently fails too. I guess this means there is no way to use mkdirs on Android? My (probably rather hacky) work-around was to create each necessary directory separately:

    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    new File(extStorageDirectory + "/one/").mkdirs();
    new File(extStorageDirectory + "/one/two/).mkdirs();
    

提交回复
热议问题