关于Android中res等几种文件通过InputStream方式读入工程中

1. res/raw下:

        InputStream is = getResources().openRawResource(R.id.xxx);

2.res/xml下:

       XmlResourceParser xmlResourceParser = getResources().getXml(R.xml.xxx);

3.src/下:

        InputStream is = getClass().getClassLoader().getResourceAsStream("xxx.xml");

4.assets/下:

        AssetManager assets = getAssets();

        InputStream is = assets.open("xxx.xml");

 

你可能感兴趣的:(Android)