Android obtains the total capacity of the SD card, available size, total body memory capacity and available size, and androidsd

Source: Internet
Author: User

Android obtains the total capacity of the SD card, available size, total body memory capacity and available size, and androidsd

Public long getSDTotalSize () {/* get the memory card path */File sdcardDir = Environment. getExternalStorageDirectory ();/* StatFs View File System space usage */StatFs statFs = new StatFs (sdcardDir. getPath (); long blockSize = statFs. getBlockSizeLong (); long totalSize = statFs. getBlockCountLong (); return blockSize * totalSize;}/*** get the remaining capacity of the SD card, that is, the size can be * @ return */public long getSdAvaliableSize () {File path = Environment. getExternalStorageDirectory (); StatFs statFs = new StatFs (path. getPath (); long blockSize = statFs. getBlockSizeLong (); long availableBlocks = statFs. getAvailableBlocksLong (); return blockSize * availableBlocks;}/*** get the body memory size * @ return */public long getRomTotalSize () {File path = Environment. getDataDirectory (); StatFs statFs = new StatFs (path. getPath (); long blockSize = statFs. getBlockSizeLong (); long tatalBlocks = statFs. getBlockCountLong (); return blockSize * tatalBlocks;}/*** get available body memory * @ return */private long getRomAvailableSize () {File path = Environment. getDataDirectory (); StatFs statFs = new StatFs (path. getPath (); long blockSize = statFs. getBlockSizeLong (); long availableBlocks = statFs. getAvailableBlocksLong (); return blockSize * availableBlocks ;}

  


The total size of the SD card displayed on the smart phone is 7967 GB, and the available space is MB.

The prompts for different brands of mobile phones or detection software are different. You can download a 360 optimized master and view your rom in the shortcut settings.




What is the difference between the total size of mobile phone SD card and mobile phone memory?

The SD card is a memory that can be obtained from a mobile phone. Like a SIM card, it is equivalent to a hard disk of a computer. If you want to play a movie, you can put the movie in the SD card, then find your movie on the SD card of your mobile phone. 1G. 2g. 4G. 8g. 16g.

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.