/ sdcard / emulated / 0和/ sdcard之间的区别 [英] differences between /sdcard/emulated/0 and /sdcard

查看:855
本文介绍了/ sdcard / emulated / 0和/ 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();
}

在/ sdcard /中创建了一个新文件夹。如果我尝试在logcat directory_path变量上打印,则路径是不同的:/ storage / emulated / 0 /
,如果我转到该路径,我会发现另一个文件夹,其名称与在/ sdcard /上创建的文件夹相同。这对我来说是个问题,因为当我尝试向该文件夹中写入一些数据时,一切都放在/ storage / emulated / 0上,而另一个(我想使用的文件夹)保持为空。
为什么?

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?

推荐答案

您是否尝试回读数据? / storage / emulated / 0 /是JB中引入的新路径,以支持平板电脑上的多个用户。但是,只要您使用 Environment.getExternalStorageDirectory()访问外部文件,它们的实际位置并不重要。

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.

以下是一些其他信息: https://android.stackexchange.com/questions/35541/why-did-sdcard-turn-into-sdcard-0-with-4-2

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

这篇关于/ sdcard / emulated / 0和/ sdcard之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆