Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 4.2 - Environment.getExternalStorageDirectory().getPath() behaviour

Tags:

android

mobile

I've been developing an android application, before the last update to 4.2, I used

Environment.getExternalStorageDirectory().getPath()

which returned me /storage/sdcard0/, but since the update I now get /storage/emulated/0.

I've been reading about the multiuser capabilities on Android 4.2 and I'm guessing that's where the 0 comes from, however, I still don't know how to get to the path I was using before the update.

like image 701
IbQuezada Avatar asked Nov 19 '12 17:11

IbQuezada


1 Answers

This is your path, so just use it. Do not think it over. Paths changed since 4.2 due to multiuser feature. Android shall deal with that on firmware upgrade so you do not need to bother. Just use it as you did so far and do not worry it changed. If your code somehow depends on old value, then fix your code.

like image 158
Marcin Orlowski Avatar answered Sep 29 '22 15:09

Marcin Orlowski