×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    19

    N9 and SQLITE database

    Hello

    i have a question about reading a SQLite Database on N9
    for symbian i used to do:
    in main file :

    Code:
    #ifdef Q_WS_SIMULATOR
    view.engine()->setOfflineStoragePath("qml/MyProject/sqlite");
    #else
    QString pathOfflineStorage(QApplication::applicationDirPath());
    pathOfflineStorage.append(QDir::separator()).append("qml/MyProject/sqlite");
    pathOfflineStorage = QDir::toNativeSeparators(pathOfflineStorage);
    view.engine()->setOfflineStoragePath(pathOfflineStorage);
    #endif
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    QFileInfo i("qml/Myproject/sqlite/Databases/bd.sqlite");
    db.setDatabaseName(QDir::toNativeSeparators(i.absoluteFilePath()));
    db.open();
    in Bd.js:

    Code:
    function getDatabase()
    {
        return openDatabaseSync("MyProject", "1.0", "ana", 100000);
    }
    it works correctly with symbian but no with meego
    any ideas??
    thanks in advance

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    20

    Re: N9 and SQLITE database

    I have similar code working. Are you sure that it is not a problem on path?

    Otherwise what it means doesn't work? it give you any error? crash?
    --------------------------------------------
    No Where Man
    Independent developer
    http://www.nowhereman.eu

  3. #3
    Registered User
    Join Date
    Jun 2012
    Posts
    105

    Re: N9 and SQLITE database

    May I ask, why do you do :
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    QFileInfo i("qml/Myproject/sqlite/Databases/bd.sqlite");
    db.setDatabaseName(QDir::toNativeSeparators(i.absoluteFilePath()));
    db.open();
    The javascript will have no use for it whatsoever.
    Also, if I remember correctly, you have to enable offline storage explicitly. I *could* post you the link with an example, but - oh - harmattan-dev is down, so.... :/

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    19

    Re: N9 and SQLITE database

    Hi nowheremanmail
    thanks for your answer the error is i can't open the data base the path of my DB : qml/MyProject/SQLite/DB/test.sqlite
    the same path worked perfectly with symbian

    thanks in advance for your help

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: N9 and SQLITE database

    It is quite easy.
    In N9 you should better use absolute path

    such as this:

    view.engine()->setOfflineStoragePath("qml/MyProject/sqlite");
    you should correct it to this path better "opt/yourProjectName/qml/MyProject/sqlite"
    yourProjectName is your real project name.

Similar Threads

  1. SQLite database and QML
    By angusr in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-03-29, 16:28
  2. SQLite and or other database.
    By shawty in forum Mobile Java General
    Replies: 6
    Last Post: 2010-03-26, 11:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×