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

前端 未结 2 424
北恋
北恋 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);
    
    0 讨论(0)
  • 2021-01-01 06:52

    You can read the file by the following code :

    InputStream object = this.getResources()
            .openRawResource(R.rawFolderName.fileName);
    
    0 讨论(0)
提交回复
热议问题