Save XML on Android

Hey guys!

I try to save my parameters on android like this:

void CustomizeMainScreen::saveDoubleVariableToXml(double ss, double bs, double ps, int br, int bg, int bb, int sr, int sg, int sb, const juce::File& xmlFile, std::string pname)
    juce::ScopedPointer<juce::XmlElement> xml = new juce::XmlElement(pname.c_str());

    // Create a child element to store the double value
    juce::XmlElement* shadowSizeElement = xml->createNewChildElement("ShadowSize");
    juce::XmlElement* borderSizeElement = xml->createNewChildElement("BorderSize");
    juce::XmlElement* pictureSizeElement = xml->createNewChildElement("PictureSize");

    juce::XmlElement* shadow_r = xml->createNewChildElement("ShadowR");
    juce::XmlElement* shadow_g = xml->createNewChildElement("ShadowG");
    juce::XmlElement* shadow_b = xml->createNewChildElement("ShadowB");

    juce::XmlElement* border_r = xml->createNewChildElement("BorderR");
    juce::XmlElement* border_g = xml->createNewChildElement("BorderG");
    juce::XmlElement* border_b = xml->createNewChildElement("BorderB");

    shadowSizeElement->setAttribute("data", juce::String(ss));
    borderSizeElement->setAttribute("data", juce::String(bs));
    pictureSizeElement->setAttribute("data", juce::String(ps));

    shadow_r->setAttribute("data", juce::String(sr));
    shadow_g->setAttribute("data", juce::String(sg));
    shadow_b->setAttribute("data", juce::String(sb));

    border_r->setAttribute("data", juce::String(br));
    border_g->setAttribute("data", juce::String(bg));
    border_b->setAttribute("data", juce::String(bb));

    // Save the XML to file


    if(xml->writeToFile(xmlFile, "")){
        juce::Logger::writeToLog("SAVE IS FINE");
        juce::Logger::writeToLog("SAVE ERROR");


It writes everything is fine.


I have a module which shows how much xml file do we have. I need to look for the xml files like this:

juce::Array<juce::File> xmlFiles;
xmlDirectory.findChildFiles(xmlFiles, juce::File::findFiles, false);
int numXmlFiles = xmlFiles.size();

if (numXmlFiles == 0) {

else {

    for (int i = 0; i < xmlFiles.size(); i++) {


nah… sometimes it finds the file (so it is saved well) sometimes no.
The xml->writeToFile(xmlFile, "") function returns true anyways.
I try to save to:
xmlDirectory = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory).getChildFile("SeamFeedDir");

On desktop, it works well everytime. I turned on READ_EXTERNAL_STORAGE in androidmanifest.

What do I miss?