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

筅森魡賤 提交于 2019-12-21 04:57:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13459280/android-4-2-environment-getexternalstoragedirectory-getpath-behaviour

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!