public class Utils {
public static List getMessages() {
//File file = new File(\"file:///android_asset/helloworld.txt\");
AssetMan
Here is a way to get an InputStream
for a file in the assets
folder without a Context
, Activity
, Fragment
or Application
. How you get the data from that InputStream
is up to you. There are plenty of suggestions for that in other answers here.
Kotlin
val inputStream = ClassLoader::class.java.classLoader?.getResourceAsStream("assets/your_file.ext")
Java
InputStream inputStream = ClassLoader.class.getClassLoader().getResourceAsStream("assets/your_file.ext");
All bets are off if a custom ClassLoader
is in play.