mardi 5 avril 2016

Sqlite locally inserted records do not persist after closing and opening the ionic app

i am doing a survey application where i am inserting the inventory records locally on-click into my Sqlite local database. Those i can see in my history view upon firing SELECT query. When i closed the app from background and again clicked on the app icon on device, my app with Splash screen gets open. Then i did login and saw the history there is nothing. What i am doing on device ready even is this:

    document.addEventListener('deviceready', onDeviceReady, false);

    function onDeviceReady() {
        // Sqlite database initialization
        try {
            db = $cordovaSQLite.openDB({name: "biziscan.db", location: 'default', iosDatabaseLocation: 'default'});
            //create table for product scan
            $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS product (id integer primary key, uniqueId text, userId text, productName text, serialNo text, manufacturer text, department text, time text, latitude text, longitude text, actionRequired text, comment text, sync text)");
        } catch (e) {
            alert(e);
        }
    }

Is the database again gets initialized on device ready or anything else is the reason???. I want my records to be persistent in the local database until user synchronizes it with the server. How can i achieve that?

Aucun commentaire:

Enregistrer un commentaire