Each time you use external storage, you should first call the Getexternalstoragestate () method to check that the storage media is available
Call the Getexternalfilesdir () method and pass in the following parameter to get the directory in the external store:
Environment.directory_music: Storing music files
Environment.directory_movies: Storing video files
Environment.directory_downloads: Storing downloaded files
Environment.directory_pictures: Storing pictures
Environment.directory_ringtones: Store ringtone file
Environment.directory_alarms: Store the beep file
Call the Getexternalstoragepublicdirectory () method to get an external common directory:
music/: The media scanner classifies the files here as music.
podcasts/: The media scanner classifies the file here as a podcast (podcast).
Ringtones/: The media scanner classifies the files here as ringtones.
alarms/: The media scanner classifies the files here as warning tones.
notifications/: The media scanner will classify the file here as a notification sound.
pictures/: Storing pictures, not including pictures taken with a camera.
Movies/: Store video, excluding videos taken with camera's camera function.
download/: Store all kinds of downloaded files.
BooleanExstoragereadable =false;BooleanExstoragewriteable =false; String State=environment.getexternalstoragestate ();if(Environment.MEDIA_MOUNTED.equals (state)) {/*can read and write external storage media*/exstoragereadable= Exstoragewriteable =true;} Else if(Environment.MEDIA_MOUNTED_READ_ONLY.equals (state)) {/*can only read, cannot write*/exstoragereadable=true; Exstoragewriteable=false;} Else { //cannot read and write, external storage media may be in one of the unavailable states described above, or other unusable statesexstoragereadable = Exstoragewriteable =false;}
SD card-Check the availability of storage media