SD card-Check the availability of storage media

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.