3

Is there any function/method which allow to detect all kind of different storage to your phone with their names. I mean to detect all internal/external storage if there is more than one available on your device. And how to detect if there is available SD Card or not?

Thanks in advance!

Android-Droid
  • 14,365
  • 41
  • 114
  • 185
  • Please see below, may be help you.
    http://stackoverflow.com/questions/7450650/how-to-list-additional-external-storage-folders-mount-points/15131810#15131810
    – boiledwater Feb 28 '13 at 09:28

2 Answers2

5

I don't know about other types of storage device, I only know Internal Storage and External Storage device for android.

Now for check available external storage something like,

public static boolean isSdPresent() {

return android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);

}

return type boolean(true->available,false->NA).

And for Internal storage, (Internal storage is always remain (present) so no need to check it) just get like,

File path = Environment.getDataDirectory();

Now, in both case to check available free memory and usage memory,

StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return Formatter.formatFileSize(this, availableBlocks * blockSize);
user370305
  • 108,599
  • 23
  • 164
  • 151
1

Try this one..

public static boolean isSdCardPresent() {

        return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

        }
Ramesh Akula
  • 5,720
  • 4
  • 43
  • 67