differences between /sdcard/emulated/0 and /sdcard

giozh picture giozh · Nov 16, 2013 · Viewed 26.3k times · Source

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?

Answer

Kai picture Kai · Nov 16, 2013

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