0

Please help.

I'm trying to create a File object using a directory path. Here is my code

String dirPath = "/app/src/main/res/xml/sample.xml";
File source = new File(dirPath);
Log.v("file test", "exists " + source.exists());

But the Log-message says that source (File object from my code sample) does not exist. But it does exist, I see it in my project structure.

4
  • you can try with this > stackoverflow.com/questions/15912825/… Commented Jun 27, 2017 at 21:11
  • Resources are not files on the device; they are entries in the APK file that is your app. Commented Jun 27, 2017 at 21:13
  • Your src directory won't be present in the deployed application. Commented Jun 27, 2017 at 22:23
  • Problem solved. sample.xml must be placed in assets-folder. Commented Jun 29, 2017 at 15:56

1 Answer 1

1

sample.xml must be placed in assets-folder in order for you to be able to access it.

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

2 Comments

Thank you man, but I have already solved the problem. Look at the last comment to my question.
I see. In that case write an answer to your own question and mark your answer as solved.

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.