Files that you choose to save in the external storage of your device are public. Anybody including the other apps in your device can review or read those files. You can modify them by permitting USB mass storage to share the files on another device.
If you have the API L version 8 or higher, the getExternalFilesDir() will help you to see a File that shows the location where you must save these files .i.e., external storage directory. Plus, this method has a special parameter that specifies the category of the subdirectory you prefer like DIRECTORY_VIDEOS and DIRECTORY_ALARMS. In this manner, you get to arrange the files, so they don’t get mixed up.
The layout of activity_main.xml is given as follows:
Other than saving and reading from external storage buttons, in this text view, we have shown the response of saving, reading from external storage.
For MainActivity.java class, the text view is shown below:
If you're using API 7th level or lower, then getExternalStorageDirectory() will do the job for you. It will open the file that denotes the origin of the external storage.
|