How to create directory automatically on SD card

If you create a File object that wraps the top-level directory you can call it’s mkdirs() method to build all the needed directories. Something like: // create a File object for the parent directory File wallpaperDirectory = new File(“/sdcard/Wallpaper/”); // have the object build the directory structure, if needed. wallpaperDirectory.mkdirs(); // create a File object … Read more

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

If your targetSdkVersion >= 24, then we have to use FileProvider class to give access to the particular file or folder to make them accessible for other apps. We create our own class inheriting FileProvider in order to make sure our FileProvider doesn’t conflict with FileProviders declared in imported dependencies as described here. Steps to … Read more