什么是存储访问XML在Android的最佳方式? [英] What's the best way to store and access XML in Android?
问题描述
虽然我知道自己的资源在XML文件中定义的,如果我有我自己的类型,我希望用一个XML文件,我应该将它们存储在RES / XML?
While I realize resources themselves are defined in XML files, if I have an XML file of my own type that I wish to use, should I be storing them in "res/xml"?
有没有更好的方式来做到这一点,如使用的资产,然后加载它们为二进制被另一个XML库解析?
Is there a better way to do this such as using assets and then loading them as binary to be parsed by another XML library?
推荐答案
我会与添加XML资源内部的 RES
文件夹中有特定的资源类型去。它的,我已经适应了,具有用于组织在同一目录下我的所有文件的约定。
I would go with adding the XML resource inside the res
folder with the specific resource type. Its a convention that I have adapted to, having all my files in the same directory for organization.
如果您在 RES / XML
它可以随时在运行时通过<一个访问中添加XML文件href="http://developer.android.com/reference/android/content/res/Resources.html#getXml%28int%29"><$c$c>Resources.getXML()$c$c>
If you add your XML file inside of res/xml
it can be accessed anytime at run-time via Resources.getXML()
这篇关于什么是存储访问XML在Android的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!