1 ImportJava.io.File;2 3 ImportCom.iss.utils.LogUtil;4 5 Importandroid.os.Environment;6 ImportAndroid.os.StatFs;7 8 /**9 * Class nameTen * @authorWang Hong He <br/> One * Get the remaining storage space tool class for your phone A * Date Created August 1, 2014 - */ - the Public classStorageutil { - - /** - * Get SD card remaining storage space + * @returnreturns a long integer value in KB bytes - */ + Public Static LongReadsdcard () { AString State =environment.getexternalstoragestate (); at if(Environment.MEDIA_MOUNTED.equals (state)) { -File Sdcarddir =environment.getexternalstoragedirectory (); -StatFs SF =NewStatFs (Sdcarddir.getpath ()); - LongBlockSize =sf.getblocksize (); - LongBlockcount =Sf.getblockcount (); - LongAvailcount =sf.getavailableblocks (); in /*LOGUTIL.D ("", "Block Size:" + BlockSize + ", block number:" + Blockcount + ", Total size:" + blockSize - * blockcount/1024 + "KB"); to LOGUTIL.D ("", "number of available blocks::" + Availcount + ", Remaining space:" + availcount * blocksize/1024 + + "KB");*/ - returnAvailcount * blocksize/1024; the}Else { * return0; $ }Panax Notoginseng } - the /** + * Get SD card remaining storage space A * @returnreturns a long integer value in M-byte units the */ + Public Static LongREADSDCARDM () { - returnReadsdcard ()/1024; $ } $ - /** - * Get the remaining storage space of the system the * @returnreturns a long integer value in kilobytes - */Wuyi Public Static LongReadsystem () { theFile root =environment.getrootdirectory (); -StatFs SF =NewStatFs (Root.getpath ()); Wu LongBlockSize =sf.getblocksize (); - LongBlockcount =Sf.getblockcount (); About LongAvailcount =sf.getavailableblocks (); $ /*LOGUTIL.D ("", "Block Size:" + BlockSize + ", block number:" + Blockcount + ", Total size:" + blockSize - * blockcount/1024 + "KB"); - LOGUTIL.D ("", "number of available blocks::" + Availcount + ", available size:" + availcount * blocksize/1024 + "KB");*/ - returnAvailcount * blocksize/1024; A } + the /** - * Get the remaining storage space of the system $ * @returnreturns a long integer value in M the */ the Public Static LongReadsystemm () { the returnReadsystem ()/1024; the } - in /** the * Determine if the remaining space is greater than the specified space the * @paramSIZEMB The specified size in megabytes About * @returnreturn value true to have corresponding space, false to be less than the corresponding space the */ the Public Static BooleanIsavailablespace (intsizemb) { the BooleanHasspace =false; + LongAvailablespare =READSDCARDM (); - if(Availablespare >sizemb) { theHasspace =true;Bayi } the returnHasspace; the } - - /** the * Determine if the remaining space is greater than the specified space the * @returnreturn value True to have 100m,false of less than 100M the */ the Public Static BooleanIsavailablespace () { - returnIsavailablespace (100); the } the}