您好我一直有getAsset()方法的麻煩。我試圖從資產文件夾中獲取一個xml文件,並將getAsset()放入inputStream中。無法解析getAssets()方法
CODE:
public class MainActivity extends AppCompatActivity {
List people;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
InputStream is = 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>
誰能告訴我怎麼回事與getAssets()方法
你面臨什麼問題?它拋出異常嗎? – KDeogharkar