0

I have the following XML file:

<setting>
  <time>12</time>
 </setting>

I used the following code to update the time value.

File file = getFileStreamPath("settings.xml");
DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc=builder.parse(file);
NodeList t=doc.getElementsByTagName("time");
Node nNode = t.item(0);
String s=time.getText().toString();
nNode.setNodeValue(s);

Unfortunately the file hasn't been updated. So how could I save the updates in the xml file?

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
Maha Adel
  • 7
  • 1
  • possible duplicate of [How to save parsed and changed DOM document in xml file?](http://stackoverflow.com/questions/4561734/how-to-save-parsed-and-changed-dom-document-in-xml-file) – Vladimir Ivanov Jan 30 '12 at 13:22
  • Thanks but there is no duplicate as this solution works in J2SE but not in android. – Maha Adel Jan 30 '12 at 15:58

0 Answers0