Copy of the base to the assets folder directory

Hello

I created a database by using the following code

bool dbHelper::CreateDataBase()
{
        QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
        bool success = false;
        database.setDatabaseName("./data/duDatabase.db");
        if (database.open())
        {
            alert(tr("Database created/registered."));
            success = true;
        } else
        {
            const QSqlError error = database.lastError();
            alert(tr("Error opening connection to the database: %1").arg(error.text()));
        }
        database.close();
        return success;

}

Now, using the "target file system browser" I see my DB inside the file data in the sandbox

My problem is:

I want to copy this DB to the folder active (I want to use as the source for a data source).

How can I do that. Please help me with a code

GOD is OK, but to the point of Curahee quotes example shows you how to use a sqlite data source database:

https://github.com/BlackBerry/Cascades-samples/tree/master/quotes

It is quite easy to use the CustomSqlDataSource class with your own SQL query

Tags: BlackBerry Developers

Similar Questions

  • Cannot create a .db file in the assets folder

    I am trying to create a quizz.db file in the current folder by creating first a temporary quizz.db in the folder data and then creating tables inside and then copy it in the current folder. By debugging code, it shows that the folder is created. But I can't find it in the current folder. Here is the code

    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::data;
    
    SQLTest::SQLTest(bb::cascades::Application *app): QObject(app)
    {
        const QString fileName = QString("quizz.db");
        QString dataFolder = QDir::homePath();
        QString newFileName = dataFolder + "/" + fileName;
        QTemporaryFile file(newFileName);
    
        // Open the file that was created
        if (file.open())
        {
            // Create an SqlDataAccess object
            SqlDataAccess sda(newFileName);
    
            // Create a table called Employee in the database file
            sda.execute("CREATE TABLE Employee( firstName VARCHAR(50),lastName VARCHAR(50), salary INT);");
    
            // Insert employee records into the table
            sda.execute("INSERT INTO Employee (firstName, lastName, salary) VALUES (\"Mike\", \"Chepesky\", 42000);");
            sda.execute("INSERT INTO Employee (firstName, lastName, salary) VALUES (\"Westlee\", \"Barichak\", 55000);");
            sda.execute("INSERT INTO Employee (firstName, lastName, salary) VALUES (\"Ian\", \"Dundas\", 47000);");
            if(sda.hasError())
            {
    
            }
            else
                copyFileToAssetsFolder("quizz.db");
        }
    }
    void SQLTest::copyFileToAssetsFolder(const QString fileName)
    {
        QString appFolder(QDir::homePath());
        appFolder.chop(4);
        QString originalFileName = appFolder + "app/native/assets/" + fileName;
        QFile newFile(originalFileName);
    // If I enable this `if` condition the code satisfies it and removes the quizz.db file and then it satisfies the next `if` condition and successfully copies the quizz.db file from `data` folder to `assets` folder.
        /*if(newFile.exists())
            QDir().remove(originalFileName);*/
        // this `if` condition is not satisfied. Which should mean the quizz.db file has been created on assets folder.
        if (!newFile.exists())
        {
            // If the file is not already in the assets folder, we copy it from the
            // data folder (read and write) to the assets folder (read only).
    
            QString dataFolder = QDir::homePath();
            QString newFileName = dataFolder + "/" + fileName;
            QFile originalFile(newFileName);
    
            if (originalFile.exists())
            {
                // Create sub folders if any creates the SQL folder for a file path like e.g. sql/quotesdb
                QFileInfo fileInfo(originalFileName);
                QDir().mkpath (fileInfo.dir().path());
    
                if(!originalFile.copy(originalFileName)) {
                    qDebug() << "Failed to copy file to path: " << originalFileName;
                }
            } else {
                qDebug() << "Failed to copy file data base file does not exists.";
            }
        }
    
       // mSourceInDataFolder = newFileName;
    }
    

    If activate the commented "If" condition of "copyFileToAssetsFolder" int he removes already created quizz.db file in the current folder (that Im unable to find) and goes inside the next ' if' and copy the quizz.db created on the folder "data" of active fodler. But in any case I don't find the quizz.db in the current folder. I really need help with this quickly. Thank you.

    Thanks to read this to learn why you can have an application change the assets folder: https://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.d...

  • Files that are opened in a bound iCloud application are instantly copied to the application folder in iCloud.

    When I open a file in any folder in the finder, in an application that is linked to iCloud, i.e. 'Expert PDF' or 'Preview', I opened, the file will be copied to the application folder instantly. This only happens on Mac.

    On Mac, the file appears in the folder something like a shortened (as in the picture):

    If I open the mobile application (i.e. PDF Expert) there is a copy of the file in the application folder.

    I first thought that would happen only with Expert PDF, but I discovered that it happens with any application that is enabled in the settings of the iCloud drive. It's really annoying to remove them, every time that you open the. That this feature was actually supposed to do, is create a folder in iCloud drive that is assigned to the application on any device to iCloud.

    Maybe someone knows how to turn it off, or maybe it's just a bug.

    It looks like a feature and not a bug.

    iCloud is not really duplicate files in the files collection of application.  It looks like a file duplicate of the same size as the original, that you have opened, but iCloud is record storage by creating symbolic links. .

    I checked several of apparent duplicates in the Terminal, and if I list the file with the Terminal command

    LS - li somefileoniclouddrive

    I see that the inodes are identical to the original and the duplicate.  So no additional storage is required.

  • Write access to the assets folder

    I have DB SQLite file liabilities. When I deploy I simply open the connection in the current folder.

    In the docs it says assets folder is a single reading file and app must copy the files that need to be writable in the application data directory in the current folder.

    However on Simulator and dev alpha I simply open the connection to db file in the current folder and are able read/change data in the db file and the changes are persisted between application restarts.

    Will be this change in behavior on an actual release or am I missing something?

    What you see is only a convenience for certain types of use during development. Signed apps do NOT have writing anywhere inside their "app" folder, which includes the current folder. You * must * copy of data / first launch, if you want to make changes to these files. Alternatively, implement a mechanism of "copy on write" if only the files that have been changed in fact never get copied, of course, which is more complicated.

  • Cannot update 3,010 FF.; Downloaded 3.6: impossible to copy in the app folder "the operation cannot be performed because you don't have sufficient privileges for some of the itemss.

    I had FF 3.0.10 for two years. My preferences are set to automatically check updates, my for a reason, it apparently never worked. I am the administrator for my Mac and have read/write permissions. The manual "check for update" under the menu help is disabled and will not work. " I tried to reset the permissions, quit and restart several times. At a given time, the window ' check for updates ' seems to be enabled, but froze when he started the download and came back to grey again. I tried to download 3.6 on your site, but when I try to drag FF in the app, I get a message that says "the operation cannot be performed because you don't have sufficient privileges for some of the items. Through it all, I noticed that my download folder is gone from the dock on my screen

    Your profile data is stored in the Firefox profile folder, so you will not lose your bookmarks and other personal data.

  • If I use "Copy as DNG" during import, I can delete the JPG LR4 copied in the destination folder?

    When I started using the LR4 I was shooting RAW + JPG on my camera.  I realized that I never use these JPG files for nothing and they are just too much room.  I thought LR4 was just import the RAW files and convert them to DNG, but when I looked in the destination folder in Windows, there are JPG files in there also.  If I have the catalogue in LR4, it shows just the DNG files and makes no mention of JPG files at all and even said after importation that "non - raw files have been imported not»

    I'm sure to go there in Windows, sort by type and then delete the jpgs?  Who will have an effect on my Lightroom Catalog?  Other discussions make mention of some of the pictures showing RAW + JPG on the thumbnail, but mine only show the DNG and don't watch no + JPG anywhere.

    I did more research for this but they all seem to apply to previous versions of lightroom or people not using not copy as DNG option.  If it is safe to delete these files jpg out, would you recommend resyncronizing folders in my catalog after you delete the jpgs?

    Thank you

    If you do not want the jpg files, and you are sure that they are not in Lightroom, then go ahead and delete them. Just be sure...

    There are no synchronization point folders if you don't know you have everything.

  • Save a copy in the specific folder and edit original

    Is it possible to bridge to make a script that:

    1. Copy a picture of the original to a particular folder another folder
    2. Give the original photo, a keyword, a label or a field of metadata with today's date?

    I've been using PHP and VBA and have just started to learn JavaScript, so I might be able to understand something of my own if you point me in the right direction. If you could give me the script ready to use, I will be very grateful.

    Our location:

    We publish photos in a weekly news journal and online. We have pictures in one folder, ready for use. When put us a picture in production copy us to another folder, but we would like to know if and when a picture has been used, so we are not using the same photo over and over again. It would be great if we can mark the original somehow "used" and "date".

    Thank you!

    Bridge CC 6.3.1.186 using x 64

    Here is an example of adding 'Used' and the date in the title field also copy the file to a selected folder.

    #target bridge
       if( BridgeTalk.appName == "bridge" ) {
    copyAndDate = MenuElement.create("command", "Copy and Date files", "at the end of Tools");
    }
    copyAndDate.onSelect = function () {
    if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
    var copyFolder = Folder.selectDialog("Please select folder to copy files to...",Folder(app.document.presentationPath));
    var sels = app.document.selections;
    for(var a in sels){
    var thumb = sels[a];
    thumb.copyTo(copyFolder);
    var md = thumb.synchronousMetadata;
    md.namespace =  "http://purl.org/dc/elements/1.1/";
    md.title = '';
    md.title = "Used " +  new XMPDateTime(new Date());
        }
    };
    
  • How to transfer files to a specific folder (or root) instead of the Assets folder?

    Is it possible, or should I go ahead and fill a feature request?

    Hello

    You can set a folder so that the download site and the full site will be downloaded to this folder. However, it is not possible to download a particular file in a specific folder.

    Kind regards

    Aish

  • Email copy in the sent folder... says to consult - sent does not exist.

    I have a snip-it of the error message. I am running Win 7 64 bit. It works great on my 32-bit system for more than 4 years. Just bought this system, but he has McAfee on it.

    McAfee is often a problem child, but not necessarily your problem.

    Is what email provider?
    Obviously, it is an IMAP account, I've never heard talk about it another way.

    Have you tent a reboot in the menu help with disabled modules? That will exclude modules as the cause.

  • I had to reformat my computer, what file are favorites stored in can I get back them. I copied Mozilla folder, I have to move my old favorites from the copy to the new folder of Mozilla. This file contains the bookmarks from last week?

    no details to add

    The profile is a file that store your personal information in a safe place

    https://support.Mozilla.com/en-us/KB/recovering%20important%20data%20from%20an%20old%20Profile

  • Toshiba 1 TB Store 'cannot copy '. "the file or directory could not be created.

    I am trying to transfer a little less 5 GB 36 996 zip data files on a network drive on my brand new Toshiba 1 TB drive. I created a directory "E:\TOSHIBA\2008-Dec" in the root but only 16386 files copied. If I try to copy files over I get windows error message "Failed to copy" "file or directory could not be created.

    Obviously the disk space should not be a problem. Any ideas? Thank you.

    What happens if you try to copy another file on the HARD disk that is larger than 5 GB?

    What file system you are using on the external HARD drive? Maybe you should try to reformat to NTFS.

    In addition, you should try another cable.

  • The message filter to copy folder imap and then msg msg in a local folder always move works again: local folder, but sometimes the msg is absent from the imap folder.

    I use a message filter to perform two actions on messages:
    (1) message copy of an imap folder
    (2) move the message to a local folder.

    Usually this works; the message is in the imap folder and local folder and is not in the Inbox. But about 10% of the time the message is present in my local folder but not the corresponding imap folder. I compare the contents of the local file and the imap folder and local folder will be messages that the imap folder is missing. I can then copy the messages in the imap folder but I want to avoid the check manually.

    Any ideas what might be happening? (I just activated the filter log see if anything interesting shows here).

    I swapped the operations to be 1) copy to the local folder, 2) move the imap folder. I put the front filter classification. This works reliably so I will mark the problem solved.

    Matt, thanks for your help!

  • I restored a few messages deleted from the Recycle Bin, but they do not appear in the original folder.

    I accidentally put the retention policy of 30 days for the wrong file, including over 1000 deleted messages. I found the messages in the trash and returned in the original folder, but all do they not appear. I immediately made a copy of the file folder in my profile, and if I look at this file, I see the missing messages. I tried to rebuild the .msf associated file and by removing the .msf file, but the messages are not displayed. How to restore access to these messages in Thunderbird? Reconstruction of the index of global data will correct this?

    If anyone is interested, I was able to restore the missing files by editing the X-Mozilla-Status codes in the file in the folder. Bit 0 x 0008 flags every message deleted. I was able to do a search/replace global for each code containing this bit in Notepad to get Thunderbird for re - index deleted messages. Of course, you'll want to do this on a copy of the affected file and keep a backup while you make the changes, just in case. Oh and do not compact your messages until you make sure that it worked.

  • Skype not opening after having moved to the Applications folder

    Back a few months ago, I downloaded Skype on my computer. I was still pretty unfamiliar with the Mac at the time, so I was not very well what to do with the dmg that I got. Simply do not know better, I ended up launching Skype from the dmg. That's how I used Skype until very recently. A few months after this happened, I learned that you were supposed to copy the application in the Applications folder on the dmg. However I did not worth to fix this error until now (in order to remove this disk image of Skype sitting there). I deleted the Skype of the dmg icon on my dock and copied in the Applications folder. I then tried to run, but it crashed before it could do something. The main window of Skype did not appear.

    If it's worth anything, there is a very old version of Skype on this computer, the surplus of when a member of the family used a few years ago. However Skype on the dmg would be fine, so I doubt that this could be the culprit.

    I am running OS X Yosemite 10.10.3 on an iMac 27-inch Mid-2010.

    We always recommend to install the latest version of Skype... That said, try this: download the latest version by clicking on the link at the top of this forum page downloads. Then, open the Skype.dmg file you will find in your downloads folder. Drag and drop the Skype icon to the icon of the folder Applications in THIS WINDOW. This will install Skype. Subsequently, you will find Skype (the application) in the Applications folder on your hard drive, where you can start. Once it launches, click right (or click/hold) Skype in the Dock icon and select Options. Choose to keep Skype in the Dock, and it will fortunately still live there then.

    --
    Entia non sunt multiplicanda praeter necessitatem.

  • I can't move original items out of the "shared" folder

    I made a new account on my macbook pro OS X 10.9.5 so the first thing I did was moved all my files in the shared folder. then after I had them in there I've moved them back, thinking that he would make a copy in the shared folder. In fact, he did the opposite. He made a copy of all my files, and that's what I have now. all the original files are always in the shared folder, and I don't know how to get out! Help, please.

    To remove the Shared folder, you will need to log in as the user that put them there. Other users cannot remove or change them.

    OS X Yosemite: share files with others using your Mac

Maybe you are looking for

  • El Capitan 10.11.3

    El Capitan 10.11.3 - same third verse of the song.  My CanoScan 9000F will no longer work with the new update.  What is so secretive that basic function cannot remain the same. Very frustrating.  Anyone know a work-a-round?

  • Sound and other issues with Satellite P100-277

    Hello dear... My English is not long but I hope you understand me... I have a laptop toshiba satellite P100-227 & Windows XP operating system.When I login to windows, the message on laptop display "cannot Access Volume Control!"I have no sound on my

  • Update office 9340f (GE Force9500 present) graphics card

    I need recommendation of a suitable replacement for the Nvidia Ge Force 9500 for best video, I'm not a gamer.

  • Different drivers in different countries

    Why Chinese and American pilots distinguishes it? China has a pilot lightning strike and a bios update while the United States has not. I checked for vn7 - 592g.http://www.Acer.com.CN/AC/zh/CN/content/drivershttp://us.Acer.com/AC/en/us/content/driver

  • Zipped file icon__

    The icon that is displayed with "compressed folder" on my computer is not a folder zipped to the top, but rather as a word document icon. Do not open the zipped files. I get an error message including the terms "because there are problems with the co