-3

I want to get sdcard and internal storage location on my android app.

I am using this code.

String sdcard = Environment.getExternalStorageDirectory().toString();

it returns storage/sdcard0.

and this code also returns the same

String sdcard = System.getenv("EXTERNAL_STORAGE");

and I am trying to get phone memory path with this code:

String internalpath = System.getenv("SECONDARY_STORAGE");

It returns storage/emulated/0 on my Android 4.4.2 that I want. However, in an Android 6.0, it returns null.

Please give me a solution to get the internal storage path like storage/emulated/0.

thanks in advance.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

please give me a solution to get the internal storage path like 'storage/emulated/0'.

Environment.getExternalStorageDirectory() usually returns a path like that, for what the Android SDK refers to as external storage.

If, on your device, that is returning something else, that is what the device manufacturer (or custom ROM developer) chose to do on that device. It is up to the device manufacturer where external storage is located, and while most devices have it as part of on-board flash, nothing is stopping a manufacturer from placing it on removable media. If you do not like this behavior, you will need to discuss that with the device manufacturer or custom ROM developer.

The Android SDK has alternative means for accessing what it refers to as internal storage and removable storage.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491