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 … Read more

android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

The app is crashing when I’m trying to open a file. It works below Android Nougat, but on Android Nougat it crashes. It only crashes when I try to open a file from the SD card, not from the system partition. Some permission problem? Sample code: File file = new File(“/storage/emulated/0/test.txt”); Intent intent = new … Read more