Search code examples
androidandroid-layoutandroid-intentandroid-hardware

getting storage information in android


I was wondering how I can get the information about any memory card, internal storage that an android device have! what I want is the free, used memory amount and if possible the extra details about memory card! ( not the internal Storage )


Solution

  • This will help you to get free memory of external storage:

    StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
    long bytesAvailable = (long)stat.getBlockSize() * (long)stat.getAvailableBlocks();
    long megAvailable = bytesAvailable / (1024 * 1024);
    Log.d("","Available MB : "+megAvailable);
    

    Hope this will help you.