Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your series of questions on this subject seem to add up to: Can I have code for a readable/writable database that uses XML formatted files on the SDCard for storage?</p> <p>That's more than I'm qualified to answer, but here is working sample code that I used when I was testing XML on BB. Hopefully this will get you started, and can I have the database code when you're finished? ;)</p> <pre><code>public class XmlManager { protected Document document; //protected Log log = new Log("XmlManager"); public XmlManager(String file) { FileConnection fc = null; InputStream inputStream = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); fc = (FileConnection)Connector.open(file, Connector.READ); inputStream = fc.openInputStream(); document = builder.parse( inputStream ); } catch (Exception e) { //log.error("builder.parse", e); } finally { try { if (fc!=null) fc.close(); if (inputStream!=null) inputStream.close(); } catch (Exception e) { //log.error("close", e); } } } public String readApiString(String tag) { Element root=document.getDocumentElement(); NodeList list = root.getElementsByTagName(tag); return(list.item(0).getFirstChild().getNodeValue()); } </code></pre> <p>example xml:</p> <pre><code>&lt;myuniquetagname&gt;foo&lt;/myuniquetagname&gt; </code></pre> <p>example usage:</p> <pre><code>XmlManager xmlManager = new XmlManager("file:///SDCard/BlackBerry/documents/myfile.xml"); String foo = xmlManager.readApiString("myuniquetagname"); </code></pre> <p>Best of luck</p> <p>Ray</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload