@ SuppressWarnings ( "deprecation" ) @ TargetApi ( Build . VERSION_CODES . JELLY_BEAN_MR2 ) public static long getAvailableCacheSlots ( String directory , int fileSize ) { StatFs statfs = new StatFs ( directory ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR2 ) { return statfs . getAvailableBytes ( ) / fileSize ; } // problem is overflow with devices with large storage, so order is important here // additionally avoid division by zero in devices with a large block size int blocksPerFile = Math . max ( fileSize / statfs . getBlockSize ( ) , 1 ) ; return statfs . getAvailableBlocks ( ) / blocksPerFile ; }
Get the number of tiles that can be stored on the file system .