Android data Storage (3): External Storage

Source: Internet
Author: User

  The third way to store data in an Android system is external Storage, which is external storage.

External storage is typically stored in public data and is stored on an expansion card or SD card.

External storage is not required, and data stored on the expansion card is not secure because all programs can access data on the expansion card and read and write data.

  

1. Use external storage to add the appropriate select, such as read_external_storage or write_exteranl_storage

   eg

    

  

2. It is important to determine if the expansion card is mounted, because the expansion card is not required for Android and is external.

An example of a judgment you write yourself:

      

Examples of Official document judgments:

     

Here:getexternalstoragestate () returns a string constant that describes the status of the expansion card.

    

3. Determine if the expansion card space is sufficient (optional)

     

4. Save the image to the expansion card (optional)

    

5. Save the image to the expansion card (optional)

    

6. Read the picture from the expansion card (optional)

    

7. Empty the expansion card

    

8. Get the name of the file

    

Note: In order for the file name to be unique, you can use the MD5 algorithm to match a name string to a unique string.

9. about the cache of external storage

    Context.getexternalcachedir ()

      

  10. Common methods for external storage

Getexternalstoragepublicdirectory ()

Getexternalfilesdir ()

Getexternalfilesdirs ()

Getexternalcachedirs ()

Not finished, to be continued.

Android data Storage (3): External Storage

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.