Every answer on this question is incomplete, and I get a lot of errors when trying to use the code.
Example: read file from assets
AssetManager am = MainActivity.getAssets();
InputStream is = am.open("book.txt");
I get errors:
- Non-static method 'getAssets()' cannot be referenced from a static context
- Cannot resolve Symbol "AssetManager", which Import do I need for this?
- context.getAssets(); context is undefined, what context do I need? MainActivity? what function do I use to get the Context of MainActivity? What imports do I need to make this work?
- Do I need to add something to Gradle files? And what?