Forums

OverviewV-Play 1 Support › Can i use Database

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #5340

    Raimonds

    Qt uses sqlite – am i right? Can i use it in v-play qml? Will it work on Android and IOS?

     

    Example

    function getDatabase() {

    return openDatabaseSync(“TestAPP”, “1.0”, “TestAPPDB”, 100000);

    }

    function initialize()
    {
    var db = getDatabase();
    db.transaction(
    function(tx) {

    tx.executeSql(‘CREATE TABLE IF NOT EXISTS someTable(field1 TEXT UNIQUE, value TEXT)’);
    tx.executeSql(‘CREATE TABLE IF NOT EXISTS someTable2(field1 TEXT UNIQUE, value TEXT)’);
    });
    }

    #5341

    Raimonds

    Raimonds said:

    Will it work on Android and IOS?

    If yes, then where i can find db file when i develop on “Desktop” mode?

    #5356

    Alex
    V-Play Team

    Hi,

    We are using it ourselves, so yes to all of your questions :)

    You can have a look at the source code of the Storage.qml file in combination with the storage.js file within the V-Play SDK. (V-PlaySDK\Desktop\V-PlaySDK\qml\VPlay\core\Storage.qml and V-PlaySDK\Desktop\V-PlaySDK\qml\VPlay\scripts\storage.js)

    The path to the .splite files on Windows is: C:\Users\<WindowsUserName>\AppData\Local\<AppName>\QML\OfflineStorage\Databases

    Best Regards,
    Alex

    #5357

    Raimonds

    Thanks Alex!

    Best Regards,

    Raimonds

    #6238

    Michael

    I feel dumb to ask this, but if I put a db file entitled “words.sqlite” into the above Windows directory, how should I compose the correponding openDatabaseSync?

    I’ve tried all sorts of variations, but each time it seems a new db is being created instead of the existing one being opened & read.

    Thanks.

    #6241

    Christian
    V-Play Team

    Hi Michael,

    if you have a look at the OfflineStorage/Databases folder, you will see there also is an ini file created. However, it does not make sense to put a manual sqlite file in there, because this approach does not work for other platforms. In the current V-Play version, there is no way to use a custom path where the sqlite file is stored or where it is read from, i.e. you cannot bundle a sqlite file with your appliation at the moment. Thus the recommended way to bundle data with your app is to save it as a json file, and then at the first application launch read the contents of this json file with fileUtils.readFile(), then call JSON.parse() for the contents and then store this data into a Storage component. You will only need to do this the first time the application starts – every consecutive call the data is already written in the Storage database.

    Cheers, Chris

    #6529

    Michael

    Hi Chris

    > you cannot bundle a sqlite file with your appliation at the moment

    Is there are plan to support local or bundled sqlite files in the future?

    I have got some feedback that the startup time is too long. I’m loading a text file. I believe at least 3-4 seconds is consumed by loading a text file, where I can remove that by opening a database.

    Cheers, Michael.

    #6543

    Christian
    V-Play Team

    Hi Michael,

    it won’t be possible unti V-Play v2.0. However, you could improve your app startup time by storing the text contents into a SQL database with the improved SQL writing that I suggested in a previous support response. Then only the first app start the values would need to be stored to the database and every additional app start your word database is already setup.

    If it is only 3-4 seconds (measure this at first by using a timer), you could also start parsing your text file after showing your main menu, so your users will see the main menu or splash screen instantly.

    Cheers, Chris

    #6550

    Michael

    Hi Chris

    Thanks. I had considered your earlier suggestion (of improved SQL writing) but thought to ask about the local sqlite db, since even having a one-time (or initial) slower load time is likely to be off-putting for some people. Thanks for your suggestion – I’ll see how I go to refactor it.

    JFYI – to give some more background info (BTW I’m using a stopwatch to measure times) for late-model devices, the current text-file loading situation is basically ok – it’s 4s from icon tap to menu-appearance (though there is black during this time, which is not ideal). I know it’s usually a 1s startup time for HelloWorld, hence quoting 3s for the load/processing of text. On older devices, I have a 6s startup time on a iPod Touch 4th Gen, and a tester reporting 5s or 8s startup time (Android HTC DesireHD 8s for post-install startup vs 5s for subsequent startups – I’ve yet to understand why there is a difference, another matter..). The situation is tolerable on the iOS due to the startup screen, but not so on the Android. I see there’s another posting on startup screens so I’ll see if that can help my situation also. Thanks again.

    Cheers, Michael.

Viewing 9 posts - 1 through 9 (of 9 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