How to access a file from asset/raw directory

Place your text file in the /assets directory under the Android project and use AssetManager class as follows to access it.

AssetManager am = context.getAssets();
InputStream is = am.open("default_book.txt");

Or you can also put the file in the /res/raw directory, from where the file can be accessed by an id as follows

InputStream is = 
context.getResources().openRawResource(R.raw.default_book);

Assets and resources are files on your development machine. They are not files on the device.

For assets, use open() on AssetManager to get an InputStream on your asset.

Also, FWIW:

  • Uri.parse("file:///android_asset/raw/default_book.txt").toString() is pointless, as it gives you the same string that you started with

  • file:///android_asset/ only works for WebView