Sto leggendo un file xml dalla scheda SD. Qui voglio cambiare i valori del file XML e voglio salvare il file nella scheda SD ..Come salvare e aggiornare i valori nel file xml?
Il mio codice è come sotto .... Per favore guidami come salvare il file XML sulla scheda SD dopo l'aggiornamento dei valori ..
public void modifyNodeval(){
try{
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File("/sdcard/sss.xml"));
//Get the staff element by tag name directly
Node nodes = doc.getElementsByTagName("Employee").item(0);
//loop the staff child node
NodeList list = nodes.getChildNodes();
for (int i =0; i<list.getLength();i++){
Node node = list.item(i);
//get the salary element, and update the value
if("Emp_Name".equals(node.getNodeName())){
node.setNodeValue("795796");
}
}
è anche una domanda simile –