How to create directory automatically on SD card

I’m trying to save my file to the following location
FileOutputStream fos = new FileOutputStream("/sdcard/Wallpaper/"+fileName);
but I’m getting the exception java.io.FileNotFoundException
However, when I put the path as "/sdcard/" it works.

Now I’m assuming that I’m not able to create directory automatically this way.

Can someone suggest how to create a directory and sub-directory using code?

14 Answers
14

Leave a Comment