javaandroidspecial-charactersmkdirmkdirs

How to create dir with special characters in Android


I need to create a folder named .ext.maps_common@transit etc. (untar archieve at other folder), I tried to use mkdir (), mkdirs (), trailing slash at its end and so on, but with no results. My final code is quite simple:

File dir = new File (".ext.maps_common@transit");
if (!dir.isDirectory ()) dir.mkdirs ();

Is it really to do this? Any help will be appreciated.


Solution

  • try this,

     File dir = new File(Environment.getExternalStorageDirectory(), ".ext.maps_common@transit");
        if (!dir.exists()) {
            dir.mkdirs();
        }
    

    and change Environment.getExternalStorageDirectory() to wherever location you want to create the directory. Don't forget to add neccessery permissions.