Yevgeny Simkin
Yevgeny Simkin

Reputation: 28359

Where do I put (and how do I read) my own custom XML in Android?

Sorry, this seems like such an obvious question, but I just can't find an answer in the docs...

I have my own XML doc (not Android related) that I need to pull and parse at run time.

Where do I store it and what's the best way to retrieve it? Do I just read it as a text document into an XML parser? Or does Android come prepared to hand me back a parsed XML object from a well formed xml?

TIA

Upvotes: 0

Views: 491

Answers (3)

Dharmendra
Dharmendra

Reputation: 33996

Best way is to put your xml in assets folder and read xml from assets.

Read xml from assets

Upvotes: 2

Ron
Ron

Reputation: 24235

You can put it in assets folder of your project.

For parsing you can use openXmlResourceParser(filename) method of AssetsManager class

XmlResourceParser parser = getResources().getAssets().openXmlResourceParser (String fileName);

Upvotes: 3

user
user

Reputation: 87064

Put it in a xml folder in res.

Upvotes: 3

Related Questions