Code example for StatFs

Methods: getBlockCountgetBlockSize

0
     * 
     * @return Total number of bytes. 
     */ 
    public static long getTotalInternalMemorySize() { 
        final File path = Environment.getDataDirectory();
        final StatFs stat = new StatFs(path.getPath());
        final long blockSize = stat.getBlockSize();
        final long totalBlocks = stat.getBlockCount();
        return totalBlocks * blockSize;
    } 
 
    /** 
     * Returns the DeviceId according to the TelephonyManager. 
     * 
     * @param context   Context for the application being reported. 
     * @return Returns the DeviceId according to the TelephonyManager or null if there is no TelephonyManager. 
     */ 
    public static String getDeviceId(Context context) {
        try { 
            final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            return tm.getDeviceId();