Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view Android/data/your.package.name files on external storage in Android 4.2 with the multi user environment?

Android 4.2 added multi user support for tablets. Now when you request a path to save files on external storage via a method like Environment.getExternalStorageDirectory() or Context.getExternalFilesDir(null) you get a value like: /storage/emulated/#/Android/data/your.package.name/ The # being a number depending on what user you are currently logged in as.

This works fine but I have noticed that DDMS's File Explorer and also the Android File Transfer are not able to see these files.

DDMS's File Explorer cannot see anything past storage/emulated/ except an empty legacy folder. File Transfer can see the /Android/data/ folder but for an app running as debug, its files are not visible (but they do exist).

Is there any way to get DDMS or File Transfer to work with these devices? (Hopefully without having to root the device...)

Thanks

like image 567
cottonBallPaws Avatar asked Nov 26 '12 22:11

cottonBallPaws


2 Answers

Aha!

Try /mnt/shell/emulated/N, for various values of N like 0. That seems to map properly on my Nexus 10 and my Galaxy Nexus in DDMS. I cannot comment on the File Transfer tool, though.

BTW, the numbers are not sequential for the users. So on my N10, the original user is 0, the second user is 10.

like image 77
CommonsWare Avatar answered Sep 21 '22 10:09

CommonsWare


As Jelly Bean 4.2 supports multi-user profiles, the sd-card browsing has been changed a bit.

You must have ADT v 21 or higher to browse emulated sd-card. /mnt/shell/emulated/0 is for default user. See the image attached for more detail.enter image description here

Enlarge Image

like image 27
AZ_ Avatar answered Sep 19 '22 10:09

AZ_