user6660129
user6660129

Reputation:

Get external storage path in android 6.0?

I'm using moto g phone which is marshmallow version I want to get path of my external memory card but I'm only able to access internal memory(after writing some permissions for marshmallow) i have tried many combinations like below for accessing external memory card

     sdpath="/storage/sdcard1";
     sdpath="/storage/extSdCard";
     sdpath="/storage/usbcard1";
     sdpath=System.getenv("SECONDARY_STORAGE");

I have accessed internal memory by writing sdpath="/storage/emulated/0"; but not able to access external memory card by above codes how can i access memory card in android marshmallow as i headr that google have changed accessing permissions from android 6.0 thanks in advance for your valuable reply.

Upvotes: 0

Views: 1176

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006819

how can i access memory card in android marshmallow

Use getExternalFilesDirs(), getExternalCacheDirs(), or getExternalMediaDirs() on Context to get at app-specific locations on removable storage.

Or, use the Storage Access Framework, to allow the user to choose a location, which may or may not be on removable storage.

Upvotes: 1

Related Questions