Forums

OverviewV-Play 2 Support (Qt 5) › Using SQLite with V-PLay

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9225

    Cal

    I have a mysql database that i have imported into a sqlite database with a utility.

    My V-PlaY app needs to make use of this database underĀ  android windows and linux ports

    Can anyone tell me where to place the database. i tried putting it in the project directory but i get file

    not found when i try to open using this javascript code

     

    function openDatabase() {
    console.log("trying to open");
    var db = Sql.openDatabaseSync("myDatabase", "1.0", "The  Database", 1000000);
    
    db.transaction(
    function(tx) {
    var rs = tx.executeSql('SELECT * FROM myTable');
    
    var r = ""
    for(var i = 0; i < rs.rows.length; i++) {
    console.log("Field1 " +rs.rows.item(i).field1);
    console.log("Field2 " + rs.rows.item(i).field2);
    }
    }
    )

     

    #9226

    Alex
    V-Play Team

    Hi,

    Unfortunately that’s not that easy as QML databases are always read from a specific location.

    If you want to use an existing database you have to copy it to a write-able location initially. Just bundle the database with your application and then copy it to the engine’s offline storage path (where all databases opened from QML are stored) retrieved with “engine.offlineStoragePath()” from your main.cpp file (you can also check if it already exists to prevent an overwrite by accident).

    Best,

    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support