SampathKumar
SampathKumar

Reputation: 2545

How to access local xml file from resource in Android?

I am new to Android application, create one xml file data.xml inside the Resource folder, then i tried to access that local xml file, but i can't get it.

But android resource folder and open rawresource to the raw folder under res inside xml file data.xml using this way, i access that xml file like:

InputStream is = this.getResources().openRawResource(R.raw.data);

but using local xml file cannot access, please help me.

Thanks

enter image description here

Upvotes: 0

Views: 3759

Answers (2)

jeet
jeet

Reputation: 29199

raw xmls should be in Assets folder, and to access files from assets folder use:

AssetManager assetManager = getAssets();
InputStream in= assetManager.open("data.xml");

Upvotes: 4

AkashG
AkashG

Reputation: 7888

Add your data.xml file under raw folder.After inserting into it you will not get this sort of error.

Upvotes: 0

Related Questions