lundi 7 décembre 2015

update a table in sqlite every 24 hours appcelerator

i have the following function in db.js where i save a json data and the updated date in two columns. i want to update the data in sqlite ios/android/windows every 24 hours. if the user opens the app after 3 days (say) then the data has to be updated. presently getting this data from an MS sharepoint API web service.

saveEmpJson : function(responseText){
    var updatedDate = new Date();
    updatedDate = updatedDate.toISOString();
    Ti.API.info (updatedDate);
    var encryptedAllEmpJson = (responseText.toString());
    myDB.execute('INSERT INTO empjson (empJSON, updatedOn) VALUES (?, ?)', encryptedAllEmpJson, updatedDate); 
//here i need to update this data every 24 hrs or more than that whenever the user opens the mobile app ios, android and windows.
i can delete this table and replace it with the updated data by calling the below function where i get the json data.
},

i have this function where i get the json data

 //fteching organization details success
var fetchOrganisationalDetailsSuccess = function (responseText) {
    db.DB.saveEmpJson(responseText);

}

i have to make sure whether the app is running in background/ closed or opened after some hours more than or equal to 24 hours.

Aucun commentaire:

Enregistrer un commentaire