Android /sdcard/emulated/0 和 /sdcard 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20017468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
differences between /sdcard/emulated/0 and /sdcard
提问by giozh
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?
在 /sdcard/ 中创建一个新文件夹。如果我尝试在 logcat directory_path 变量上打印,路径是不同的: /storage/emulated/0/ 并且如果我转到该路径,我会找到另一个与 /sdcard/ 上创建的文件夹同名的文件夹。这对我来说是一个问题,因为当我尝试将一些数据写入该文件夹时,所有内容都在 /storage/emulated/0 上的一个中,而另一个(即我想要使用的文件夹)保持为空。为什么?
回答by Kai
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.
你试过读回数据吗?/storage/emulated/0/ 是 JB 中引入的新路径,用于支持平板电脑上的多个用户。但是只要您使用Environment.getExternalStorageDirectory()
它访问外部文件,它们真正驻留在何处并不重要。
Here's some additional info: https://android.stackexchange.com/questions/35541/why-did-sdcard-turn-into-sdcard-0-with-4-2
这里有一些额外的信息:https: //android.stackexchange.com/questions/35541/why-did-sdcard-turn-into-sdcard-0-with-4-2
回答by duggu
/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+)
/storage/emulated/0/:据我所知,这是指“模拟 MMC”(“所有者部分”)。通常这是内部的。这里的“0”代表用户,“0”是第一个用户,也就是设备所有者。如果您创建更多用户,则每个用户的数量都会增加。
/storage/emulated/legacy/ 和以前一样,但指向当前工作用户的部分(对于所有者,这将是指向
/存储/模拟/0/)。所以这条路应该把每个用户带到他的“部分”。
/sdcard/:根据 Shywim 的评论,这是一个符号链接...
/mnt/sdcard (Android < 4.0)
/storage/sdcard0 (Android 4.0+)
For more detail you can visit stackexchange
有关更多详细信息,您可以访问stackexchange