How to read local xml file is resource folder as a input stream in android?

前端 未结 2 455
北恋
北恋 2021-01-01 06:03

I am trying to get input stream from something like this.

InputSource myInputSource = new InputSource(activity.getResources().openRawResource(com.MYCLass.R.x         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 06:37

    Put the xml file into /res/raw folder. It looks like openRawResource opens resources from that folder only. You can also try getResources().getXml(com.MYCLass.R.xml.programs); which will return you an instance of XML parser.

    A piece of code taken from @Krupa

    InputStream object = this.getResources()
                         .openRawResource(R.raw.fileName);
    

提交回复
热议问题