android - cannot resolve getAssets() method -


hi have been having trouble getasset() method. trying xml file assets folder getasset() put inputstream.

code:

public class mainactivity extends appcompatactivity {     list people;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          try {             inputstream =  getassets().open("people.xml");             people = xmlparser.readpeople(is);         }catch (ioexception e){             e.printstacktrace();         }     } } 

xml:

<people>    <person>        <name>joe</name>        <dob>11/08/16</dob>        <gender>male</gender>    </person> </people> 

can tell me going on getassets() method

instead of this

      try {             inputstream =  getassets().open("people.xml");             people = xmlparser.readpeople(is);         }catch (ioexception e){             e.printstacktrace();         } 

use

        try {                assetmanager assetmanager = getbasecontext().getassets();                 inputstream =  assetmanager.open("people.xml");                 people = xmlparser.readpeople(is);             }catch (ioexception e){                 e.printstacktrace();             } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -