Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Deploy Sqlite db file on iOS and Winphone?

Deploy Sqlite db file on iOS and Winphone?

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 777 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlekseyShi
    wrote on 21 Nov 2016, 06:21 last edited by
    #1

    Code below it works on Android, but how to do same on iOS and Winphone?

    QFile dfile("assets:/db/database-last.db3");
    if (dfile.exists())
    {
        dfile.copy("./database-last.db3");
        QFile::setPermissions("./database-last.db3",QFile::WriteOwner |     QFile::ReadOwner);
     }
    

    ...

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("./database-last.db3");
    db.open();
    

    ...

    in .pro file

    deployment.files += database-last.db3
    deployment.path = /assets/db
    INSTALLS += deployment
    
    J 1 Reply Last reply 21 Nov 2016, 06:31
    0
    • A AlekseyShi
      21 Nov 2016, 06:21

      Code below it works on Android, but how to do same on iOS and Winphone?

      QFile dfile("assets:/db/database-last.db3");
      if (dfile.exists())
      {
          dfile.copy("./database-last.db3");
          QFile::setPermissions("./database-last.db3",QFile::WriteOwner |     QFile::ReadOwner);
       }
      

      ...

      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
      db.setDatabaseName("./database-last.db3");
      db.open();
      

      ...

      in .pro file

      deployment.files += database-last.db3
      deployment.path = /assets/db
      INSTALLS += deployment
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 21 Nov 2016, 06:31 last edited by
      #2

      @AlekseyShi Here you try to write in current directory:

      dfile.copy("./database-last.db3");
      

      This not going to work then that directory isn't writeable by your application (and the installation directory of an mobile app isn't writable!).
      You should use one of the standard directories from http://doc.qt.io/qt-5/qstandardpaths.html (QStandardPaths::AppDataLocation)

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlekseyShi
        wrote on 21 Nov 2016, 06:41 last edited by AlekseyShi
        #3

        It works on Android by set permissions. My question is for iOS and Winphone concerning to pack dbfile into *.dmg.
        *But I'll try your advice too. :)

        1 Reply Last reply
        0

        1/3

        21 Nov 2016, 06:21

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved