/*** Method of obtaining SD information*/ Private voidGetsd () {//TODO auto-generated Method StubFile path=environment.getexternalstoragedirectory (); StatFs Stat=NewStatFs (Path.getpath ()); LongBlocksize=stat.getblocksize (); Longtotalblacks=Stat.getblockcount (); Longavailableblocks=stat.getavailableblocks (); Longtotalsize=blocksize*totalblacks; Longavailsize=availableblocks*blockSize; String Totalstr=formatter.formatfilesize (mainactivity. This, totalsize); String Availstr=formatter.formatfilesize (mainactivity. This, availsize); Mtextviewshow.settext ("The total capacity of the SD card is" +totalstr+ "\ n" + "The available capacity of the SD card is" +availstr); }
//android How to get phone memory/*** How to get phone memory *@return */ PrivateString Getromspaceinfo () {File path=environment.getdatadirectory (); StatFs Stat=NewStatFs (Path.getpath ()); LongBlocksize=stat.getblocksize (); Longtotalblocks=Stat.getblockcount (); Longavailableblocks=stat.getavailableblocks (); Longtotalsize=blocksize*totalblocks; Longavailsize=availableblocks*blockSize; String Totalstr=formatter.formatfilesize (mainactivity. This, totalsize); String Availstr=formatter.formatfilesize (mainactivity. This, availsize); return"Memory of Phone: Total space" +totalstr+ "\ n" +Availstr; }
Android about getting SD card phone memory capacity