Xamarin – Reading XML File from SD Card in Android

In one of my previous posts we had seen how to read a text file from SD Card. In this post we would see how to read an XML file from SD Card.


Let’s say, we have the following xml file.


Copy the file to the SD Card using one of the following methods:

  1. Using Eclipse DDMS Tool
  2. Using ADB.EXE
  3. Using WinImage Tool


Now, we would have a simple layout design. We would have a button and TextView control. On click of the Button; the xml file would be read and the contents of the file would be displayed in the TextView control.


The following is the xml file for string resources used.


First of all, we would have the controls from our layout and then subscribe to the click event of the button.


Then in the click event, we would have the XDocument, to help us reading the xml file. And finally we would display it in the TextView.


Let’s run the application and see this in action.


On Button click the xml file content is displayed.


Hope this post helps, thanks for reading.

Full Source Code: Click Here