I would like to know how I can retrieve device information on my Android mobile application as the free internal memory available on the device.
            Asked
            
        
        
            Active
            
        
            Viewed 45 times
        
    -1
            
            
        - 
                    1Please read this to see how to ask a good question: http://stackoverflow.com/help/how-to-ask. Question does not show any form of research – 0xDEADC0DE May 11 '16 at 12:22
- 
                    I think you can find your answer here http://stackoverflow.com/questions/8133417/android-get-free-size-of-internal-external-memory – Hayk Petrosyan May 11 '16 at 12:27
2 Answers
0
            
            
        Here is a function I've been using to get the available memory at any given time :
public static long getAllowedMemory() {
    final long defaultValue = 16l * 1024l * 1024l;
    final Runtime runtime = Runtime.getRuntime();
    if (runtime != null) {
        final Long value = runtime.maxMemory();
        if (value == Long.MAX_VALUE) {
            // No value available
            return defaultValue;
        } else {
            return value;
        }
    }
    return defaultValue;
}
 
    
    
        NSimon
        
- 5,212
- 2
- 22
- 36
0
            Try this. following code returns Internal Storage Memory in MB ,
StatFs stat = new StatFs(Environment.getDataDirectory().getPath());
long bytesAvailable = (long)stat.getFreeBlocks() * (long)stat.getBlockSize();
long megAvailable = bytesAvailable / 1048576;
 
    
    
        Sathish Kumar J
        
- 4,280
- 1
- 20
- 48
 
    