Created
November 17, 2015 19:56
-
-
Save mitchross/b012bd72a9cd3b1f92c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MemoryUtility | |
{ | |
public static long getTotalInternalMemory( Context context ) | |
{ | |
long totalSpace = new File(context.getFilesDir().getAbsoluteFile().toString()).getTotalSpace(); | |
return totalSpace; | |
} | |
public static long getTotalUnusedMemory( Context context ) | |
{ | |
long freeBytesInternal = new File(context.getFilesDir().getAbsoluteFile().toString()).getFreeSpace(); | |
return freeBytesInternal; | |
} | |
public static float getPercentageMemoryFree(Context context) | |
{ | |
long total = getTotalInternalMemory(context); | |
long avail = getTotalUnusedMemory(context); | |
float percentage = ((float)avail / (float)total); | |
return percentage; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment