0

Is it possible to save an image from an url in the assets folder?

void DataPacking::createAndSaveImage(QString argSavingFilePath,
        QByteArray argDataLoaded) {
    m_file = new QFile;
    m_file->setFileName(argSavingFilePath);
    m_file->open(QIODevice::WriteOnly);
    m_file->write(argDataLoaded);
    m_file->close();
    m_file->~QFile();
}

m_savingFilePath = QDir::homePath() + "app/native/assets/images/"
            + QString("multipleActive.png");

createAndSaveImage(m_savingFilePath, m_dataLoaded);

but when I try to use this image, I am getting the error below.

"Unable to get asset in (/apps/com.bluewave.LeasePlan.testDev_e_LeasePlan45b0f435/native/assets/): (/images/multipleActive.png)."

László Papp
  • 51,870
  • 39
  • 111
  • 135
oumaimadev
  • 69
  • 7

1 Answers1

3

The assets directory (or more properly the app directory) is part of the protected area of the application sandbox that can not be changed. If you want to store data in the sandbox you should use the data directory.

See: https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_system.html

Richard
  • 8,920
  • 2
  • 18
  • 24
  • If you mean update a database that is in the assets directory, no you can not. If you want to provide an initial DB during install you can put that in the assets directory, then copy it over to the data or db directory on fist run. – Richard Dec 16 '13 at 18:30
  • But.. it works? If I have .db in assets and use SqlDataAccess in qt I can update it. It doesn't work from QML though. I know it should be in /data or /db, but honestly, these things need more explaining and examples – Bojan Kogoj Dec 16 '13 at 22:16
  • 1
    It works for developer installs, but release packages have only read-only access to the assets folder. – onion Dec 17 '13 at 11:31
  • 1
    There are a lot of things that work for a dev install that won't work in production. The IDE only uploads files that have changed. They couldn't do that if the developer sandbox was locked down as tight as production. One reason side-loading Android ports from some sources might not be wise. I can browse my developer installs with the IDE, I can't browse production installs, even of my own programs. – Richard Dec 17 '13 at 14:27
  • Asset folder is Read Only at Run time. Modifying files in asset should woks in developer mode, not in Production mode. – pranavjayadev Jul 16 '14 at 07:58
  • @PranavJDev that's what I said in my answer. – Richard Jul 16 '14 at 19:23