错误路径试图在Android中打开文件 [英] Bad path trying to open file in Android

查看:119
本文介绍了错误路径试图在Android中打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打开一个文件,这样的:

I'm trying to open a file with this:

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

和我得到这个消息:

/Data.xml:打开失败:ENOENT(没有这样的文件或目录)

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

和文件在Android项目的根目录。

and the file is in the root directory of the android project.

推荐答案

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

You are trying to open a file located in / (in linux this is the root directory of your file system). Instead you should be trying to create a file either on the SDCard or within the local storage directory for your application.

更多的澄清看到这一点。 COM /引导/主题/数据/数据​​storage.html

See this for more clarification: http://developer.android.com/guide/topics/data/data-storage.html

这篇关于错误路径试图在Android中打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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