Skip to content Skip to sidebar Skip to footer

Best Way To Know Sd Card Path Android

I need to know in the most of the devices the sd card path. I have some problems for that I actually use: Environment.getExternalStorageDirectory(); But some phones don't return

Solution 1:

There is no "sd card path" in Android.

At the present time, Android has internal storage and external storage, and that is it. Environment.getExternalStorageDirectory(); returns the root of external storage. Whether external storage is:

  • on the same partition of the on-board flash as is used for internal storage, or
  • on a separate partition of the on-board flash, or
  • is some removable drive, like a microSD card, or
  • is something else entirely

is up to the device manufacturer.

Similarly, if the device manufacturer offers additional data stores (e.g., a removable card in addition to external storage as part of on-board flash), right now, those additional data stores are for the exclusive use of the device manufacturer. That manufacturer may elect to document how you can use them, or the manufacturer may integrate those data stores with something else that you can access (e.g., have multimedia files by indexed and accessible via MediaStore).

You can read more about this in the documentation on external storage.

So, by definition, Environment.getExternalStorageDirectory();is "the correct path" representing external storage.

Solution 2:

I think this is best one ...

Cursorcursor= getContentResolver().query(_uri, newString[] { ndroid.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
                      cursor.moveToFirst();

Solution 3:

This is always the best approach:

Environment.getExternalStorageDirectory();

You could also get the environmental variable which is on all Android devices like this:

StringsdcardPath= System.getenv("EXTERNAL_STORAGE");

Post a Comment for "Best Way To Know Sd Card Path Android"