0

My devices is HuaWei NEM-TL100H , run Android 6.0。When I get the sdcard path using the flowing code :

File sdcard = Environment.getExternalStorageDirectory();

but it return

/storage/E635-0F94/

I am sure the read and write external storage permission had request and the target sdk version is 22 in my project.

Does anyone meet the same issue?

What I expected it will return the path like /storage/emulated/legacy/ or /storage/emulated/0/ but not /storage/E635-0F94/

In fact , after I adb shell into device , and ls /storage folder , there are 4 sub folders listed : E635-0F94 , emulated,sdcard0,sdcard1 . Does the E635-0F94 is another link to sdcard0 or sdcard1 ?

binkery
  • 295
  • 1
  • 3
  • 9
  • Read this article: http://stackoverflow.com/questions/6049114/environment-getexternalstoragedirectory-does-not-return-the-path-to-the-removabl?rq=1 – Stanojkovic Oct 18 '16 at 14:28
  • 1
    And what exactly is your issue? It's called `getExternalStorageDirectory` not `getExternalStorageDirectoryHumanReadableName`. – Eugen Pechanec Oct 18 '16 at 14:40
  • "When I get the sdcard path" -- that code has nothing to do with an SD card on most Android devices. [External storage](https://commonsware.com/blog/2014/04/08/storage-situation-external-storage.html) is not [removable storage](https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html). – CommonsWare Oct 18 '16 at 15:18
  • `/storage/E635-0F94/` That is a perfect path for a micro SD card. Only stange that it is returned by that function for external storage. – greenapps Oct 18 '16 at 18:17
  • @greenapps In my mind , it will return the path like /storage/emulated/legacy/ or /storage/emulated/0/ but not /storage/E635-0F94 . – binkery Oct 20 '16 at 02:26
  • In your post there is stil `it return /storage/E635-0F94/`. What we have to believe? And where were you complaining about? All is contradictory. – greenapps Oct 20 '16 at 11:06
  • `after I adb shell into device`. Wrong. Of course you should use a file Explorer app on the device itself. And if you want to know if two folders are the same then compare their contents. – greenapps Oct 20 '16 at 11:16

1 Answers1

-1

Fetch all data:

ArrayList<String> filesList = new ArrayList<String>();   
String sd_card = Environment.getExternalStorageDirectory().toString();
file = new File( sd_card ) ;       
File list[] = file.listFiles();
for( int i=0; i< list.length; i++) {
    filesList.add( list[i].getName() );
}

Don't forget to add permission in manifest:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Stanojkovic
  • 1,612
  • 1
  • 17
  • 24
  • Question was not asked for getting the file lists. Also he has specifically mentioned that he has given all required permission – Sanjeet Oct 18 '16 at 15:09