views:

406

answers:

1

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"?

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?

+4  A: 

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.

If you add your XML file inside of res/xml it can be accessed anytime at run-time via Resources.getXML()

Anthony Forloney
Do you know which API I'll end up using when loading XML through Resource?
Omega
I am kind of confused what you mean by which API, can you clarify a bit more?
Anthony Forloney
What type of parser is used? Is there an Android API reference? More simply, what type of object does Resources.getXML() return?
Omega
It returns back an `XmlResourceParser` from the Android API
Anthony Forloney
Also parsing XML files with the XmlPullParser returned by Resources.getXml() is 10x-100x faster than parsing a raw file, since the built tools preprocess the XML file into a binary representation.
hackbod
Not bad! Good to get that noted, I'll make special efforts to continue with this. Thanks so much.
Omega