This article describes the tool class for obtaining sdcard size and memory size implemented by Android development. Share it for your reference, as follows:
public class SDCardUtil { /** * SD card * @param context */ public static void getSDCardInfo(Context context){ try { File path = (); StatFs s = new StatFs(()); long availableBlocks = (); long blockCount = (); long blockSize = (); long totalsize = blockSize * blockCount; long availsize = blockSize * availableBlocks; String totalsizeStr = (context, totalsize); String availsizeStr = (context, availsize); } catch (Exception e) { (); } } /** * Mobile phone memory * @param context */ public static void getDataInfo(Context context){ try { File path = (); StatFs s = new StatFs(()); long availableBlocks = (); long blockCount = (); long blockSize = (); long totalsize = blockSize * blockCount; long availsize = blockSize * availableBlocks; String totalsizeStr = (context, totalsize); String availsizeStr = (context, availsize); } catch (Exception e) { (); } } }
For more information about Android related content, please check out the topic of this site:A summary of SD card operation methods for Android programming and development》、《Android file operation skills summary》、《Android database operation skills summary》、《Android programming activity operation skills summary》、《Android development introduction and advanced tutorial》、《Android resource operation skills summary》、《Android View View Tips Summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.