List of usage examples for android.os Environment getDataDirectory
public static File getDataDirectory()
From source file:Main.java
public static long getTotalInternalMemorySize() { File path = Environment.getDataDirectory(); mStatFs.restat(path.getPath());//from w w w . j a v a2s .c o m long blockSize = mStatFs.getBlockSize(); long totalBlocks = mStatFs.getBlockCount(); return totalBlocks * blockSize; }
From source file:Main.java
public static long getAvailableInternalMemorySize() { File path = Environment.getDataDirectory(); mStatFs.restat(path.getPath());//from w ww.j a v a 2 s. c om long blockSize = mStatFs.getBlockSize(); long availableBlocks = mStatFs.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
/** * @return The total storage in MegaBytes *//* www . j a v a2s.com*/ public static Long getTotalInternalDataSize() { StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); long size = stat.getBlockCount() * stat.getBlockSize(); return size / BYTES_TO_MB; }
From source file:Main.java
/** * @return The available storage in MegaBytes */// w w w .j ava2 s.c o m public static Long getAvailableInternalDataSize() { StatFs stat = new StatFs(Environment.getDataDirectory().getPath()); long size = stat.getAvailableBlocks() * stat.getBlockSize(); return size / BYTES_TO_MB; }
From source file:Main.java
public static File getDir() { String rootDir = ""; if (Environment.isExternalStorageEmulated()) { rootDir = Environment.getExternalStorageDirectory().toString() + "/" + Environment.DIRECTORY_DCIM; } else {/*from ww w . java 2 s .co m*/ rootDir = Environment.getDataDirectory().toString() + "/" + Environment.DIRECTORY_DCIM; } File imageDirectory = new File(rootDir); if (!imageDirectory.exists()) { imageDirectory.mkdirs(); } return imageDirectory; }
From source file:Main.java
public static long[] getRomMemroy() { long[] romInfo = new long[2]; //Total rom memory romInfo[0] = getTotalInternalMemorySize(); //Available rom memory File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); romInfo[1] = blockSize * availableBlocks; return romInfo; }
From source file:Main.java
/** * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM./*from ww w . j a v a 2 s .com*/ * * @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; }
From source file:Main.java
/** * Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM.// ww w . j a v a2 s. c om * * @return Number of bytes available. */ public static long getAvailableInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize = stat.getBlockSize(); final long availableBlocks = stat.getAvailableBlocks(); return availableBlocks * blockSize; }
From source file:Main.java
/** * get the space is left over on phone self */// ww w . java2s . co m public static long getRealSizeOnPhone() { File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); long realSize = blockSize * availableBlocks; return realSize; }
From source file:Main.java
/** * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM./*w w w . j a v a 2s .c om*/ * * @return Total number of bytes. */ public static long getTotalInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize; final long totalBlocks; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = stat.getBlockSizeLong(); totalBlocks = stat.getBlockCountLong(); } else { //noinspection deprecation blockSize = stat.getBlockSize(); //noinspection deprecation totalBlocks = stat.getBlockCount(); } return totalBlocks * blockSize; }