将 XML 文件保存到正在运行的 Android 项目
首先:查看我的问题 在线读取 XML 并存储它(使用 Java)。阅读已批准的答案以及该答案下方的评论。
所以,我的问题是:即使我已经完成了链接问题中描述的过程,并且 .xml 文件保存到我的 Android 应用程序中的 /res/values 文件夹中,但它根本不显示 - 不显示我正在运行应用程序,也没有在关闭应用程序后运行。
有谁知道如何解决此问题,以便当我生成文件时,即使应用程序正在运行,也可以立即读取和使用它?
First: see my question Reading XML online and Storing It (Using Java). Read the approved answers and the comments underneath that answer.
So, what my question here is: even though I've run through the process described in the linked question, and the .xml file saves to the /res/values folder in my Android App, its not showing up at all - not when I'm running the app, nor after I close the app.
Does anyone have any ideas on how to fix this so that when I generate the file, it will be available right away, even while the app is running, to read and use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需使用此代码,
您就可以在
data/data/packagename/file
文件夹 Thnx 中看到您的xml
文件。希望这会对您有所帮助。just use this code,
and you can see your
xml
file at thedata/data/packagename/file
folder Thnx. Hope this will help you.我不能 100% 确定您是否在 Java 中运行 XML 解析,或者实际上在 Android 应用程序中运行。
如果您在 Java 中运行,请注意您的项目结构不在模拟器中 - .apk 在运行之前已打包并安装。您需要使用 adb 将文件推送到模拟器(或您的 Android 设备)中,然后您的应用才能看到该文件。
如果您在应用程序中访问该文件:
如果您使用 openFileOutput() 等文件访问方法,它将显示在设备上的私有目录中,即 /data/data//files/
但是,如果您使用“new File(”而不是“context” .openFileOutput”,那么该文件就位于您放置的位置。
I'm not 100% sure if you're running the XML parsing in Java or actually in your Android app.
If you're running in Java, be aware that your project structure isn't live in the emulator - the .apk was packaged up and installed before running. You need to use adb to push files into the emulator (or your Android device) before your app can see the file.
If you're accessing the file in the app:
If you use file access methods such as openFileOutput() it will show up in the private directory on the device, which would be /data/data//files/
However, if you're using "new File(" rather than "context.openFileOutput" then the file is wherever you put it.