Android path to asset txt file

android, assets, file, path

Solution

AssetFileDescriptor descriptor = getAssets().openFd("myfile.txt");
FileReader reader = new FileReader(descriptor.getFileDescriptor());

Try using the above with FileDescriptors. Seems to be the most foolproof way I've found to gather asset paths.

Problem

I'm doing: `FileReader fin = new FileReader("file:///android_asset/myFile.txt");` in an Android project and many variations. At runtime I get a file not found exception. The file is present and correct in the assets folder, so my path must be wrong. What is the absolute path I need here?

Original source

Related problems