zoukankan      html  css  js  c++  java
  • Android获取SD卡总容量,可用大小,机身内存总容量及可用大小

    public long getSDTotalSize()
    {
        /*获取存储卡路径*/
        File sdcardDir= Environment.getExternalStorageDirectory();
        /*StatFs 看文件系统空间使用情况*/
        StatFs statFs=new StatFs(sdcardDir.getPath());
        long blockSize= statFs.getBlockSizeLong();
    
        long totalSize=statFs.getBlockCountLong();
    
        return blockSize*totalSize;
    }
    
        /**
         * 获得sd卡剩余容量,即可以大小
         * @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;
        }
    
        /**
         * 获得机身内存大小
         * @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;
        }
    
        /**
         * 获得机身可用内存
         * @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;
        }
    

      

  • 相关阅读:
    循环链表问题
    非常有用的编程学习网站
    我的单例模式(C++)
    C# xml解析
    设计模式趣解
    简单工厂(C++)
    贝塞尔曲线 原理
    C++ 1.#QNAN0;1.#QNAN0
    [NOI2018]屠龙勇士 excrt
    [NOI.AC#30]candy 贪心
  • 原文地址:https://www.cnblogs.com/smiler/p/3854761.html
Copyright © 2011-2022 走看看