android - 尝试在 Android 中打开文件的错误路径

标签 android file path

我试图用这个打开一个文件:

document = builder.parse(new File("Data.xml"));

我收到这条消息:

/Data.xml: open failed: ENOENT (No such file or directory)

并且该文件在android项目的根目录下。

最佳答案

您正在尝试打开位于 / 中的文件(在 linux 中,这是您的文件系统的根目录)。相反,您应该尝试在 SDCard 上或本地存储目录中为您的应用程序创建一个文件。

请参阅此以获得更多说明:http://developer.android.com/guide/topics/data/data-storage.html

关于android - 尝试在 Android 中打开文件的错误路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10235888/

相关文章:

java - 如果没有给出值,如何制作if语句

Android 0nTouch 事件问题 [Swipe DOWN and UP]

java - 这个位图的inSampleSize计算方法有什么问题?内存不足

android - 应用启动后如何去除AppBar阴影

python - 如何从 Python 中的文件路径中提取文件夹路径?

file - access to file to files tomcat的conf文件夹下的一个文件

bash - bash 不是运算符的奇怪之处

c# - 如何以编程方式获取另一个应用程序的安装路径?

silverlight - WPF : Stretching multiple paths relatively

java - 将 URL 转换为普通 Windows 文件名 Java 6