Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android devices with Environment.getExternalStorageDirectory() != /mnt/sdcard/?

Of course in my code I use Environment.getExternalStorageDirectory() instead of hardwiring /mnt/sdcard/. But I just realized that when I export data from my application via a database dump in an exchange format, file paths are /mnt/sdcard/... This may explain some strange errors that I have seen in the logs from users.

I will make the appropriate changes in the import modules. But I am curious - does any Android devices > 1.6 have Environment.getExternalStorageDirectory() != /mnt/sdcard/ ?

like image 343
Giulio Prisco Avatar asked Jun 01 '11 17:06

Giulio Prisco


Video Answer


3 Answers

No. I haven't seen any devices with sdcard mounted to different location. And I've played with more then 10 different devices from most popular vendors.

Having said that, you shouldn't rely on this fact. Especially if you have such an easy way to get path to External storage.

like image 39
inazaruk Avatar answered Sep 29 '22 21:09

inazaruk


I had a user of one of my apps report this, he was using Andy 2.2 IIRC but I can't remember what device he was using. The path can be found using

Environment.getExternalStorageDirectory().getPath()

I think the path my user got was /sdcard & not /mnt/sdcard like my HTC phone does.

like image 42
daveD Avatar answered Sep 29 '22 23:09

daveD


Actually, some for some devices the getExternalStorageDirectory() will return localization for internal memory (internal SD card). The removable SD card is located as mount point below, usually getExternalStorageDirectory()+"/sd" or getExternalStorageDirectory()+"/external_sd". Unfortunately, there is no standard for this and you won't know what kind of storage you are pointing at.

like image 70
tomash Avatar answered Sep 29 '22 23:09

tomash