How to get URI from an asset File?

后端 未结 11 1481
慢半拍i
慢半拍i 2020-11-22 14:27

I have been trying to get the URI path for an asset file.

uri = Uri.fromFile(new File(\"//assets/mydemo.txt\"));

When I check if the file

11条回答
  •  伪装坚强ぢ
    2020-11-22 14:52

    Try this out, it works:

    InputStream in_s = 
        getClass().getClassLoader().getResourceAsStream("TopBrands.xml");
    

    If you get a Null Value Exception, try this (with class TopBrandData):

    InputStream in_s1 =
        TopBrandData.class.getResourceAsStream("/assets/TopBrands.xml");
    

提交回复
热议问题