1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
public class XmlConfig {
private int niveau_zoom;
public XmlConfig()
{
String configFilePath= Environment.getExternalStorageDirectory()+"/Projet/config.xml";
try {
configFileStr = new FileInputStream(configFilePath);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setInput(configFileStr, null);
int eventType = parser.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT) {
switch(eventType) {
case XmlPullParser.START_DOCUMENT:
break;
case XmlPullParser.START_TAG:
String tagName = parser.getName();
if(tagName.equalsIgnoreCase("Zoom")) {
niveau_zoom = Integer.parseInt(parser.getAttributeValue(0));
}
}
catch (XmlPullParserException e) { }
}
public int getnZoom()
{
return niveau_zoom;
}
} |
Partager