10

I am running KitKat on a tablet with two users: primary (owner) and secondary. I need to access a file generated by an app of the secondary user.

When I plug the tablet into my (Ubuntu) desktop via USB, it mounts as a media device (MTP), and shows me the base folder for the currently active user. [1] But the file I want is elsewhere on the system, so I connected from the command line via adb shell instead.

Connecting via ADB gives me access to deeper folders (/mnt /proc etc) but I couldn't find the file where I expected it [2], so I looked in /sdcard anyway. To my surprise I recognised the contents as the base folder of the owner account, even though the currently active user is the secondary user.

This also tells me that, if I ever need to, I won't be able to access the base folder for the secondary user via adb shell.

How can I access the tablet from adb shell as the secondary user, rather than the primary (owner) user? (Being able to access the secondary user's files is good enough.)

[1] I'm not sure what the proper term here is. I mean the folder with Android, Download and Pictures, specific to a particular user.

[2] FWIW I am exporting an OPML file from Flym. Flym reports that the OPML export is generated at /storage/emulated/10/Flym_123456789.opml but I can only get as far as /storage/emulated - there is no subfolder called 10, only legacy which is the same as /sdcard (the primary/owner's base folder, not the secondary user's base folder).

1

2 Answers 2

4

The legacy/ locations are always pointing to the data of the currently active user. Let me first point to a few related questions/answers explicitly dealing with those multi-user storage issues for some background:

So to find the files of the secondary user:

  • list the sub-directories of /data/media and /storage/emulated
  • restrict your search to sub-directories whose names are simply "numbers"
  • the 0 candidates belong to the owner, higher numbers are of secondary users
  • external storage is something different: /sdcard/0 points to the internal sdcard, while /sdcard/1 should be the external (if available). Similarly for storage attached via OTG

Remember you might need to be root to access data of a user other than the one currently active on the device.

Also see:

7
  • this helps me understand what I should see, but what I actually see is just /storage/emulated/legacy (no numeric folders) and I don't have access to /data/media (permission denied) - I'm going to try restarting and never logging in as owner
    – lofidevops
    Commented Dec 4, 2014 at 12:18
  • As I wrote: "you might need to be root" (which explains the "permission denied"). Is your device rooted?
    – Izzy
    Commented Dec 4, 2014 at 13:37
  • it isn't (a bit scared to, seems like there is no reliable process?)
    – lofidevops
    Commented Dec 4, 2014 at 13:45
  • but I can confirm this: reboot device, don't log in as owner, log in as secondary, hook up usb, access via MTP: can see secondary user folder, access via adb shell: can see /storage/emulated/legacy as owner user (not secondary user) - no other folders appear under /storage/emulated
    – lofidevops
    Commented Dec 4, 2014 at 13:46
  • When logged in with the secondary user, emulated/ should point to the secondary user's data. No way to access all without root. And correct, there's no official process to root your device; you might want to check our rooting tag-wiki and rooting index to check for generals and for your device. If not listed, be welcome to ask a new question for this.
    – Izzy
    Commented Dec 4, 2014 at 13:50
1

In Android 13 I finally found the folder at /data/media/USERID

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .