Back to project page HistoryCleanerPro.
The source code is released under:
Copyright (c) 2014, John Phillips All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project HistoryCleanerPro listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.ayros.historycleaner.helpers; /*from ww w .j ava 2 s . c o m*/ import java.io.StringReader; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; public class PrefsModifier { private String prefData; public PrefsModifier(String path) { prefData = RootHelper.getFileContents(path); } public String getValue(String key) { if (prefData == null) { return null; } XPath xpath = XPathFactory.newInstance().newXPath(); InputSource source = new InputSource(new StringReader(prefData)); String expression = "//*[@name='" + key + "']"; try { NodeList nodes = (NodeList) xpath.evaluate(expression, source, XPathConstants.NODESET); if (nodes.getLength() != 1) { return null; } Node n = nodes.item(0); return n.getTextContent(); } catch (Exception e) { return null; } } }