How can I get relative path of the folders in my android project?

前端 未结 8 1719
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 19:16

How can I get the relative path of the folders in my project using code?

I\'ve created a new folder in my project and I want its relative path so no matter where the

8条回答
  •  一个人的身影
    2020-12-08 20:11

    Make use of the classpath.

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL url = classLoader.getResource("path/to/folder");
    File file = new File(url.toURI());
    // ...
    

提交回复
热议问题