1

I am facing some weird problem regarding is memory card present or not. I am checking for IsSDCARD present its returing true on my google nexus device but when i try to access memory card from eclipse using file explorer its showing no memory card in mnt folder(the arrao before memory card is not present)....Here is my code please help

  public static boolean isSDCardMounted() {
    Boolean isSDPresent = android.os.Environment.getExternalStorageState()
            .equals(android.os.Environment.MEDIA_MOUNTED);
    Log.d("Tag", "SDCARD PRESENT....." + isSDPresent);
    return isSDPresent;
}

 if (!DownLoadFile.isSDCardMounted()) {
            CommonFunctions.showAlerts(MainActivity.this,
                    "SD Card Not Available");
            if (progressDialog.isShowing())
                progressDialog.dismiss();
            cancel(true);
        }

Please help.....

newBie
  • 118
  • 11

2 Answers2

1

Check for

public static boolean isExternalStorageRemovable ()

Added in API level 9

Returns whether the primary "external" storage device is removable. If true is returned, this device is for example an SD card that the user can remove. If false is returned, the storage is built into the device and can not be physically removed.

Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be "external storage". On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash More on this already answered by @CommonsWare here https://stackoverflow.com/a/5695129/786337

https://stackoverflow.com/a/15612964/786337

Community
  • 1
  • 1
Tarun
  • 13,727
  • 8
  • 42
  • 57
0

Use below line Use Environment.getExternalStorageState() as described in "Using the External Storage".

To get available space on external storage, use StatFs:

// do this only *after* you have checked external storage state:
File extdir = Environment.getExternalStorageDirectory();
File stats = new StatFs(extdir.getAbsolutePath());
int availableBytes = stats.getAvailableBlocks() * stats.getBlockSize();

The code to check all details of memory card is mention in below http://sapienmobile.com/?p=204

chaitanya
  • 1,726
  • 2
  • 17
  • 13