I am inside a fragment in this class:
public class NetworksList extends Fragment{
Also inside my function onCreate, I have this piece of code:
XmlPullParserFactory pullParserFactory;
try {
pullParserFactory = XmlPullParserFactory.newInstance();
XmlPullParser parser = pullParserFactory.newPullParser();
InputStream in_s = getActivity().getApplicationContext().getAssets().open("temp.xml");
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(in_s, null);
Toast.makeText(getActivity().getApplicationContext(), "size: ", Toast.LENGTH_LONG).show();
parseXML(parser);
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
A wish that I am trying to use to open XML files. I have an XML file in the resource folder, but I get:
05-08 18:03:11.034 24645-24645/pt.smartgeo.aees W/System.err﹕ java.io.FileNotFoundException: temp.xml
05-08 18:03:11.034 24645-24645/pt.smartgeo.aees W/System.err﹕ at android.content.res.AssetManager.openAsset(Native Method)
05-08 18:03:11.034 24645-24645/pt.smartgeo.aees W/System.err﹕ at android.content.res.AssetManager.open(AssetManager.java:316)
05-08 18:03:11.034 24645-24645/pt.smartgeo.aees W/System.err﹕ at android.content.res.AssetManager.open(AssetManager.java:290)
05-08 18:03:11.034 24645-24645/pt.smartgeo.aees W/System.err﹕ at pt.smartgeo.aees.NetworksList$2.onClick(NetworksList.java:77)
FileNotFound ... How do I know where to place the temp.xml file so that I can open it in my NetworkList class?
source
share