我在此位置的SD卡中有一些文件:
/Android/data/com.abc.xyz/files/main.1.com.abc.xyz.obb/myfile.xml
我正在尝试从上面的路径读取文件并返回一个输入流,但输入的stram返回为null,我已检查路径也是正确的。
InputStream inputStream = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
}
// here filepath is the path that i have added above.
inputStream = classLoader.getResourceAsStream(filePath);
return inputStream;
}
为什么我会变空?