Keeping tables in a database

So my app creates a table if it doesn’t exist where I am able to add records and have the entered data relist in a grid. I am able to update selected records in the table on another form and grid. But if I close AppStudio for the day and go back into the app the next day all the data in the table is gone.

What am I missing if I want to maintain the table data for later testing.

Thanks in advance,

Perhaps the easiest way is to save the data in localStorage. When your app restarts, check to see if there is data in localStorage and load it back into the grid.

The JSON.stringify and JSON.parse functions are handy ways to convert arrays to strings and vice versa. (The data in localStorage should be a string).

Note that localStorage isn’t guaranteed to preserve data during everything which can happen on a phone. If the data is critical, you’ll want to save it in the cloud somehow.

Hi, thank you for the reply.
This app is creating a sqlLite database and being developed for an iPad or other tablet. I have the idea of a user loading inventory data into several related tables in the database during the day. If they don’t complete their work and come back the next day to resume their count, they’ll lose everything as the tables will have been dropped. So I’ll have to export the data and then import it the next day? I guess I am not understanding the concept of sqlLite DBs on a mobile device. How does Northwind work since the data seems to always be there when I test the sample app?

Thanks again.

You didn’t mention you were using WebSQL.

WebSQL has its own storage area - no need to use localStorage. Not all browsers support WebSQL - are you making desktop or Android/iOS app?

Well, there I go again for assuming everybody knows what I am talking about :slight_smile:

So I will not know what OS a user may have, so I was planning for both android and iOS.

Thanks again.

Android and iOS will both work the same way. If you use a Cordova plugin for SQLite, the data will persist on the device.

Super…thanks. I’ll give that a try.