Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] LocalStorage not persisting across program sessions on Android
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] LocalStorage not persisting across program sessions on Android

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 1.1k Views 1 Watching
  • 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
    abates
    wrote on last edited by
    #1

    Me again, sorry!

    I've been using the excellent LocalStorage method of storing data on my Android device. Sample code:
    @ var db=LocalStorage.openDatabaseSync("MyDB","1.0","This is my DB",1000000);
    db.transaction(
    function(tx) {
    tx.executeSql('CREATE TABLE IF NOT EXISTS ATable(dataname TEXT, latestdatetime TEXT)');
    tx.executeSql("INSERT INTO ATable VALUES ('Hats','0')");
    })@
    It works very well for storing the data in, and once I've used insert statements, I can get the data back out using selects. However when I exit the application and start it back up, the database starts up blank. I tried using QSqlDatabase functions in the C++ section of my code and got the same result.

    I have the WRITE_EXTERNAL_STORAGE permission in my AndroidManifest.xml. Is there anything else I need to do to make the data persist between instances of the program?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      abates
      wrote on last edited by
      #2

      Ah, never mind. It appears that whenever I press the Run button, since QtCreator is redeploying the app, it's also causing the app's data on the device to reset. Running up the app on the device without going via QtCreator results in the data persisting.

      1 Reply Last reply
      0

      • Login

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