hai every one. i am new to android. in my project i had some problems reading xml files. In my xml i have included some audios and videos paths and i want to read the xml file through the code and i want to display some images n my view if there are some audio or video files. can any body tel how to read the xml file.
thanking you in advance
hai every one. i am new to android. in my project i had some
Share
Ok first you need to create a parser Below is the code to do this:
public static void readTemplateFile(Context context) {
You then need a Handler Class. In the above example my class is called XML_Handler_Template.
FileReader( new File(Environment.getExternalStorageDirectory().getPath() + “/FILEPATH/FILE.XML” ));
Here is the XML_Handler_Class at the moment it is blank:
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class XML_Handler_Template extends DefaultHandler{
}
have a play with this and see how you get on for now =0) I passed a context to the class so whilst i was learning I could use toasts to show me the values that were being read.