i am trying to parse an XML file using SAX. The problem is that I
need to make the method Static because I want to run this method
inside the "onCreate" methods of the "DatabaseHelper" class (Which is
a static inner class).
This is not really an android issue but a scope issue.
The problem is at this line:
XmlListHandler listXmlHandler = new XmlListHandler();
Eclipse shows me this error:
"No enclosing instance of type SpellDroidDbAdapter is accessible. Must
qualify the allocation with an enclosing instance of type
SpellDroidDbAdapter (e.g. x.new A() where x is an instance of
SpellDroidDbAdapter)."
/*
* Insert a List into the database from an XML file
*
* @param xmlFile a List XML file
*/
public static void insertNewListFromXML(File xmlFile) {
try {
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-
Reader*/
XmlListHandler listXmlHandler = new XmlListHandler();
//Set the Handler
xr.setContentHandler(listXmlHandler);
// Parse the xml-data from our URL.
xr.parse(xmlFile.getAbsolutePath());
} catch (Exception e) {
/* Display any Error to the GUI. */
Log.e(TAG, "List Insertion Error", e);
//TODO display a toast to the user of the error
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---