Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

differences between /sdcard/emulated/0 and /sdcard

I'm goig to be mad with a strange issue. If i create a folder inside my code as

directory_path = Environment.getExternalStorageDirectory()
                + "/" + context.getResources().getString(R.string.app_name);

directory = new File(directory_path);
if (!directory.exists()) {
    directory.mkdirs();
}

a new folder is created inside /sdcard/ . If i try to print on logcat directory_path variable, the path is different: /storage/emulated/0/ and if i go to that path, i found another folder with the same name of the one created on /sdcard/ . This is a problem for me because when i try to write some data into that folder, everithing goes in the one on /storage/emulated/0 , and the other one (that is the folder i want use) remain empty. Why?

like image 634
giozh Avatar asked Nov 16 '13 10:11

giozh


2 Answers

Have you tried reading back the data? /storage/emulated/0/ is the new path introduced in JB to support multiple users on tablet. But as long as you access external files using Environment.getExternalStorageDirectory() it doesn't really matter where they really reside.

Here's some additional info: https://android.stackexchange.com/questions/35541/why-did-sdcard-turn-into-sdcard-0-with-4-2

like image 182
Kai Avatar answered Oct 08 '22 19:10

Kai


/storage/emulated/0/: to my knowledge, this refers to the "emulated MMC" ("owner part"). Usually this is the internal one. The "0" stands for the user here, "0" is the first user aka device-owner. If you create additional users, this number will increment for each.

/storage/emulated/legacy/ as before, but pointing to the part of the currently working user (for the owner, this would be a symlink to

/storage/emulated/0/). So this path should bring every user to his "part".

/sdcard/: According to a comment by Shywim, this is a symlink to...

/mnt/sdcard (Android < 4.0)

/storage/sdcard0 (Android 4.0+)

For more detail you can visit stackexchange

like image 39
duggu Avatar answered Oct 08 '22 19:10

duggu