Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
esam_tec
Posts: 85
Registered: ‎06-22-2013
My Device: N/A
Accepted Solution

App release problem, help .

I have developed an app with data base reading and writing (SQLData access).

on Debug or Run it works perfect but when i'm creating a Release and run it the app reads only from the data base.

Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: App release problem, help .

Did you move your database to the data folder?

 

The assets folder is not writable outside of debug.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
esam_tec
Posts: 85
Registered: ‎06-22-2013
My Device: N/A

Re: App release problem, help .

how do i do that ?
Developer
BBSJdev
Posts: 6,118
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: App release problem, help .

Something like this...

 

bool DbHelper::copyDbToDataFolder(const QString databaseName)
{
    // Since we need read and write access to the data base it has
    // to be moved to a folder where we have access to it. First
    // we check if the file already exists (previously copied)
    QString dataFolder = QDir::homePath();
    QString newFileName = dataFolder + "/" + databaseName;
    QFile newFile( newFileName );

    if (!newFile.exists()) {
        // If the file is not already in the data folder we copy it from the
        // assets folder (read only) to the data folder (read and write).
        // Note that on a debug build you will be able to write to a data base
        // in the assets folder but that is not possible on a signed application.
        QString appFolder(QDir::homePath());
        appFolder.chop(4);
        QString originalFileName = appFolder + "app/native/assets/sql/" + databaseName;
        QFile originalFile( originalFileName );

        if (originalFile.exists()) {
            return originalFile.copy(newFileName);
        } else {
            qWarning() << "Failed to copy file, database file does not exist.";
            return false;
        }

    }

    return true;
}

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.