Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Save a XML file in Android

$
0
0

Hello,

I am trying to save some data on the phone, for when the user closes the app. I thought the best way to do this is via XML (correct me if I am wrong).

So it works fine in Java mode, but when I switch to android it doesn't.

XML xml = loadXML("database.xml");
    XML amount_tot_liter_xml = xml.getChild("amount_tot_liter");
    println(amount_tot_liter_xml.getFloatContent());

The database.xml is inside the data folder. I can read data from the file. But I can't save data:

    xml.removeChild(amount_tot_liter_xml);
    amount_tot_liter_xml = xml.addChild("amount_tot_liter");
    amount_tot_liter_xml.setFloatContent(amount_tot_liter);
    saveXML(xml, "data/database.xml");

Viewing all articles
Browse latest Browse all 941