0

I have problems with adding a non-android xml file init.xml to android project in Eclipse. This file is used to initialize some simulation process, which is not connected with android. Eclipse doesn't recognize it if simply put it into project directory and write something like

File file = new File("init.xml");

Should I declare the file in some specific way or put it into other directory?

5 Answers 5

3

You can put this file inside the assets folder and then you can access this file by using AssetManager and getAssets().

AssetManager assetManager = getAssets();
InputStream instream = assetManager.open("init.xml");
Sign up to request clarification or add additional context in comments.

3 Comments

What if I need to use it like a field of type File? I have a method SimulationEngine.init(File file);
HI paresh : off topic , and i am in blacked_state : can you please tell me why we use this file in android . dropbox.com/s/rcjdtychzahimeb/toParesh.png
@TusharPandey no idea, BTW what's that blacked_state exactly?
3

Put it into the /res/xml directory and access it as a resource with Resources.getXML().

See: http://developer.android.com/guide/topics/resources/providing-resources.html

Comments

2

You should put these files in the assets/ directory and then access them via the AssetManager.

Comments

0

Why don't you put it on the assets folder, to get it from there just use this:

Activity.getAssets().open(...) //with your file..

Comments

-1

you can put the file res/layout and dont forget 2 give extension .xml i hope it would be already wd extension .xml

and you can acces that xml on source page like

(R.layout.xml name )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.