Recently I started to get acquainted with android studio, I went through several lessons, but I just won’t understand. There is a res folder with other folders in it, let's say I create a folder “A” there, and in it there will be a file “D. *”. Here's how to specify the path to it via "File * - new File ();" ?
1 answer
No, it is impossible to access.
You need to put the file in a special directory - assets ( src/main/assets/ ). If not, you need to create it.
After this, you can retrieve the InputStream of this file, read-only.
InputStream stream = getAssets().open("filename"); After that, if necessary, you can save this file to the file system - https://stackoverflow.com/a/21730182/1159507
- A little bit wrong. I started to learn jsoup, and there to open a html file local, then I need to register the following line: File input = new File ("/ tmp / input.html"); Document doc = Jsoup.parse (input, "UTF-8", " example.com/" ); - SneQ AstC 1:53 pm
Jsouphas aparsemethod that takes anInputStreaminstead of aFile. Those. you just need to replace input with stream. - anber 2:26 pm- I'll try. And what about the directory. This tree is created in the res folder, where there are other folders layout, menu, etc., or the assetc folder should be at the res folder level? - SneQ AstC
- Read the answer carefully. - anber
|