21

I've never seen this before so I'm assuming that it happened when I upgraded to 4.2: I'm fairly certain that /sdcard/ used to take me straight to my sdcard, but now when I go to that path (in CWM recovery for example) I need to go to /sdcard/0, there's also /sdcard/legacy knocking about suddenly.

What are these folders and why have they appeared?

1 Answer 1

24

That has to do with the Multi-User feature enabled with JellyBean 4.2 (not 4.1). In order to handle separate accounts, parts of the directory structure had to be changed. /sdcard/legacy e.g. always points to the currently logged-in user's sd card directory.

I currently cannot find the document where I read the details, so I cannot link any source. But with the above in mind, it's easy to guess that /sdcard/0 will most-likely be the device owners (or "first users" -- the "first user" always becomed the "device owner", only this user can create additional accounts) sd card, and so on. I will add a link to a source as soon as I can find it.

EDIT: One of the pages I got that idea from is AndroidNext. 1droid gives a different explanation when it comes to sd card:

With Android 4.2, Google introduced multiple users as a new feature. In order to accommodate multiple users, Google is now giving each user a their own folder for storage. If you upgraded to 4.2 from 4.1, then the 4.2 ROM will look for a certain file in /data to determine whether it needs to migrate all of your files to the new multi-user data structure. By default, 4.2 migrates all of /data/media to /data/media/0.

A problem arose though with custom recoveries. A custom recovery retains the /data/media folder during a factory reset. When you factory reset and then boot a 4.2 ROM again, the 4.2 ROM will migrate everything in /data/media again. It will migrate your files every time you factory reset. This multiple migration is what resulted in some people having their files moved to /sdcard/0 or even /sdcard/0/0 etc.

So it has in fact to do with the new Multi-User feature -- one way or the other.

4
  • You are a gentleman and a scholar, great answer. Your theory about 0 being the first user also makes sense since I only have one user, and /sdcard/0 is the only "number directory" that exists.
    – pzkpfw
    Commented Dec 17, 2012 at 11:01
  • Also relevant to this is Dan Morrill's explanation of why Android moved from USB Mass Storage to MTP access for the internal storage, which touches on the "fake" /sdcard/ fodler issue androidpolice.com/2011/11/18/…
    – GAThrawn
    Commented Feb 13, 2013 at 14:52
  • Though I strongly disagree with him on the "file picker" question (I already bookmarked that article a while ago). We're not at Cupertino here, nor we Gnomish. We don't have to hide things, and tell the user what he really wants (though he "might not know yet"). I prefer the options, whatever defaults are set. Make it a general switch in the config: "Yes, I'm a mature user" / "No, I rather like other people deciding for me"... Apart from that: Good point :)
    – Izzy
    Commented Feb 13, 2013 at 15:27
  • In Android6 (Marshmallo), /storage/emulated/legacy turns empty (at least on Nexus devices), where before upgrading to Marshmallow it contained the same as /storage/emulated/0 Commented Dec 4, 2015 at 21:43

You must log in to answer this question.

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