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)
  1. how to solve my problem ,so many try but i am not able to solve my problem ,

Please ,Help me .

Answers


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.


Need Your Help

Using Textarea Within Swiper Slider (Disable Touch Events)

javascript jquery textarea slide swiper

I'm using the idangerous "Swiper" slider. One of my slides has a textarea in it that is causing issues. Everything is OK on the desktop, but on mobile when entering text in the textarea, Swiper see...

WPF Window does not load UserControl

c# wpf user-controls

I guess I've got a pretty simple problem. I'm tying show a usercontrol via contentcontrol.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.