Note that there are some explanatory texts on larger screens.

plurals
  1. PORead Assets file as string
    primarykey
    data
    text
    <p>I would like to read the content of a file located in the Assets as a String. For example, a text document located in <code>src/main/assets/</code></p> <p><strong>Original Question</strong><br> <em>I found that this question is mostly used as a 'FAQ' for reading an assets file, therefore I summarized the question above. Below is my original naive question</em></p> <p>I'm trying to read a assets file as string, I tried like 20 answers here but they don't work for me.</p> <p>I have a file in my assets folder: data.opml, and I have to put the content in a string. I send it like:</p> <pre><code> OPML.importFromFile(string, MainTabActivity.this); </code></pre> <p>And receive it like:</p> <pre><code> importFromFile(String filename, Context context); </code></pre> <p>Something that did work (but it's not a assets file):</p> <pre><code> OPML.importFromFile(new StringBuilder(Environment.getExternalStorageDirectory().toString()).append(File.separator).append(fileNames[which]).toString(),MainTabActivity.this); </code></pre> <p>I've tried:</p> <pre><code> AssetFileDescriptor descriptor = getAssets().openFd("data.opml"); FileReader reader = new FileReader(descriptor.getFileDescriptor()); And also: InputStream input = getAssets().open("data.opml"); Reader reader = new InputStreamReader(input, "UTF-8"); </code></pre> <p>Maby I'm doing something wrong, but it just won't work because it the project gives errors (respectively: OPML is not capable for the arguments filereader and reader) , If somebody knows how to do this, it would be very appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload