1

Usually I can put an xml-file (of non-android format, the same would be if I need, f.e., to use .txt file) into my project directory and use it by

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

This doesn't work with android project, so I need a solution.

P.S. Asset manager doesn't work in this case, because I need to work exactly with a field of File type, but AM only provides the following method

InputStream open(String fileName);
1

3 Answers 3

2

Put it in your res folder and access it with R.foo.bar The path to the file.

Sign up to request clarification or add additional context in comments.

Comments

1

I believe you can place the file in the resource path and use something like the following to access it

InputStream is = context.getResources().openRawResource(R.xml.myfile);

Comments

0

Where did you put your file? I think it'll work if you put it in a "raw" folder in your project.

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.