android 获取配置文件 相对路径

--src

  --com.example.Demo1

    --IndexActivity.class

        --test.txt  

在IndexActivity.class 获取test.txt中的文件内容

InputStream inputStream = getClass().getResourceAsStream("test.txt");

//getClass().getResourceAsStream("path");    获取当前类的path,例如此例中就为 /com.example.Demo1/path

原文地址:https://www.cnblogs.com/lianghui66/p/3302934.html