parse plist from sdcard in android
In my project parse plist from sdcard.
I have done one example that takes a xml file from resource belove code.
Resources res = activity.getResources(); XmlResourceParser xpp = res.getXml(R.xml.myplist);
but i want to
XmlResourceParser xpp = (SDCARD xml file)
- how to solve my problem ,so many try but i am not able to solve my problem ,
Please ,Help me .
You should substitute the XmlResourceParser with XmlPullParser. The first one is for parsing xml from resources folder, the latter - for parsing xml from InputStream. From then on you need to construct an InputStream from the sdcard:
File file = new File (path-to-your-file); fileInputStream fis = new FileInputStream(file); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(fis, "UTF-8");// or whatever encoding suites you
EDIT: BTW I am interested in the way you implemented to parse plist in android.